Showing posts with label openquery. Show all posts
Showing posts with label openquery. Show all posts

Friday, 12 November 2010

SQL Server: How to deal with Acucobol date fields

   


As explained in a previous post, you can connect your Sql Server to an Acucobol db using AcuODBC. In the last part of the article I explained that there are performance issues when you query a linked server with OpenQuery and that it is better to import relevant data from the linked server to a Sql Server table in order to benefit from all the features available through stored procedures, triggers and so on.
I run some queries overnight  using SQL Scheduler to keep my local tables updated against the Acucobol tables, but, when importing the data, in some way I manipulate them to make them easier to query. What I found important in terms of performance, is to convert date fields from int to smalldatetime format. Furthermore, when importing data I insert into the newly created Sql Server table an identity field and set it as primary key.
Let's break down the query and I will explain it bit by bit.

Monday, 8 November 2010

SQL Server: How to connect and query Active Directory

   


You might need to query your domain's Active Directory for different reasons. There are limitations in doing so (which I explain below), but in case you need to retrieve those information anyway, here's how to do it.
First of all, we need to create a new linked server in SQL Server. You can connect to Active Directory executing the following small stored procedure:
EXEC master.dbo.sp_addlinkedserver @server = N'ADSI',
@srvproduct=N'Active Directory Services', @provider=N'ADsDSOObject',
@datasrc=N'W2k3dc'