Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
SQL
SET NOCOUNT ON;

Exec sp_configure 'show advanced options', 1;
RECONFIGURE;
GO

Exec sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO

SELECT ID,FirstName,Surname
FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=C:\AddressBook.mdb')...[tblContacts]

--SELECT [Field1],[Field2],[Field3],[Field4]
--FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=Location:\Filename.mdb')
...[TableName]

Exec sp_configure 'Ad Hoc Distributed Queries', 0;
RECONFIGURE;
GO

Exec sp_configure 'show advanced options', 0
RECONFIGURE;
GO
Posted
Updated 30-Sep-13 23:11pm
v3
Comments
Thanks7872 1-Oct-13 5:18am    
Ask to those who have written this.

By Using the above Code... we can access the Contents Of the table 'tblContacts' from AddressBook.mdb (MS-Access File) Present in C Drive...

U can try this Code...
First Create a ms access File in c drive and name it as AddressBook and create a table 'tblContacts' with columns ID,Firstname,Surname.. and provide some sample data...

By using the above code u can view the contents of tblContacts in SqlServer....

Read these: OPENDATASOURCe[^]
Ad Hoc Quieries[^]
 
Share this answer
 
Comments
Member 10256268 1-Oct-13 5:25am    
i want retrieve one table from mdb plus how to that.
Member 10256268 1-Oct-13 5:26am    
i want retrieve one table from mdb plus how to do that.
Everything is explained on MSDN -TechNet site:
sp_configure[^]
OPENDATASOURCE[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900