Wednesday, January 30, 2008

Access Link Server

In my first implementation of MS CRM 3.0, I have to integrate MS CRM 3.0 with an application which is developed in MS Access. I have to create a stored procedure which picks data from access database and insert or update the corresponding CRM custom entity's table. For this purpose I created a link server in SQL Server 2005 for access. Here is the code of creating that link server


-- ========================================
-- Add Linked Server Access MDB template
-- ========================================
EXEC sp_addlinkedserver
@server = 'InboxAccessDB',
@provider = 'Microsoft.Jet.OLEDB.4.0',
@srvproduct = 'Access',
@datasrc = 'D:\INBOX\CRM\Inbox Access DB\Report-Deliver 02-05-2007_be.mdb'
GO
-- Set up login mapping using current user's security context
EXEC sp_addlinkedsrvlogin
@rmtsrvname = 'InboxAccessDB',
@useself = 'TRUE',
@locallogin = NULL,
@rmtuser = 'Admin',
@rmtpassword = 'inboxdata'
GO
-- List the tables on the linked server
EXEC sp_tables_ex 'InboxAccessDB'
GO

No comments: