Friday, March 23, 2012

How to run queries in SQL Server using Access files

Hello All,
I am new to SQL Server. I have an Access database and I want o run SQL
queries in SQL Server. I have alredy run SQL queries using this database in
Access but cant do it in SQL Server. Can someone advise?
--
NeerajYes of course. You have to setup the access database as a linked server or
have to use the OPENROWSET or OPENDATASOURCE. I like working with linked
server if you use they permanently. You can access them via the four-part
name schema naming the object as below:
Select * from LinkedServername...ObjectName
More on this is on the BOL with some good examples, makes sure that the path
you define in the settings of the Access database is serverbased. so the
access db has to be reached from the server to use it.
Sample:
USE master
GO
-- To use named parameters:
EXEC sp_addlinkedserver
@.server = 'SEATTLE Mktg',
@.provider = 'Microsoft.Jet.OLEDB.4.0',
@.srvproduct = 'OLE DB Provider for Jet',
@.datasrc = 'C:\MSOffice\Access\Samples\Northwind.mdb'
GO
-- OR to use no named parameters:
USE master
GO
EXEC sp_addlinkedserver
'SEATTLE Mktg',
'OLE DB Provider for Jet',
'Microsoft.Jet.OLEDB.4.0',
'C:\MSOffice\Access\Samples\Northwind.mdb'
GO
HTH, Jens Suessmeyer.
--
http://www.sqlserver2005.de
--
"Neeraj" <Neeraj@.discussions.microsoft.com> schrieb im Newsbeitrag
news:FE0A89AE-C691-4D46-A2F5-CA38A7D161F8@.microsoft.com...
> Hello All,
> I am new to SQL Server. I have an Access database and I want o run SQL
> queries in SQL Server. I have alredy run SQL queries using this database
> in
> Access but cant do it in SQL Server. Can someone advise?
> --
> Neeraj

No comments:

Post a Comment