SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Other Forums
 MS Access
 Insert data from Access to SQL server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sanjay_jadam
Yak Posting Veteran

India
53 Posts

Posted - 12/06/2005 :  08:54:53  Show Profile  Reply with Quote
How can i access data from MS-Access using SQL query in SQL Server 2000 ??

ditch
Flowing Fount of Yak Knowledge

South Africa
1417 Posts

Posted - 12/06/2005 :  08:57:34  Show Profile  Visit ditch's Homepage  Reply with Quote
Books OnLine is your freind.

Look Up "OPENROWSET"

Duane.
Go to Top of Page

Plotin
Starting Member

USA
21 Posts

Posted - 12/06/2005 :  11:27:56  Show Profile  Reply with Quote
Books Online includes a whole chapter called Distributed Queries on this topic

You can link Access to SQL Server using stored procedure sp_addlinkedserver as followed

sp_addlinkedserver 'ServerName', 'Access 95', 'Microsoft.Jet.OLEDB.4.0', 'C:\SomPath\SomeFile.mdb'

ServerName is the name you assign to the linked server
Access 95 specifies the version of Access
Microsoft.Jet.OLEDB.4.0 is the OLEDB driver
C:\SomPath\SomeFile.mdb is the path to the Access file you want to access

Once the file is linked, you can use sp_tables_ex or sp_columns_ex to check if the file has been linked properly.
These to stor procs give you info about the meta data of your Access file.

When the file has been linked correctly you are able run T-SQL statements against the linked server

You refer to a table in your Access file using a fully qualified identifier like
MyServer...MyTable

For Example using the assigned server name Access above and and imaginary table like Address a SELECT statement would look like this

Select *
From Access...MyTable

Once you are done using the linked server you drop it by using sp_dropserver SERVERNAME

One can use this technique also for linking Excel or Text files






Plotin
Go to Top of Page

Plotin
Starting Member

USA
21 Posts

Posted - 12/06/2005 :  11:30:45  Show Profile  Reply with Quote
Sorry, linking the Access file to SQL would require to put this into a stored procedure in order to use it in a query.

Plotin
Go to Top of Page

Plotin
Starting Member

USA
21 Posts

Posted - 12/06/2005 :  11:41:59  Show Profile  Reply with Quote
Just tried OpenRowSet but returned the following error

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. Authentication failed.
[OLE/DB provider returned message: Cannot start your application. The workgroup information file is missing or opened exclusively by another user.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80040e4d: Authentication failed.].

Here is the T-SQL statement used

SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'c:\MKBD.mdb';'admin';'mypwd', ArticleID)

Does someone know what to do?



Plotin
Go to Top of Page

afrika
Flowing Fount of Yak Knowledge

Nigeria
2702 Posts

Posted - 12/08/2005 :  07:06:50  Show Profile  Reply with Quote
open the access file, then click open or Ctrl + O

then in the file types choose ODBC connection and point it to your SQL server app and corresponding table


Afrika

Edited by - afrika on 12/08/2005 07:10:15
Go to Top of Page

yuemb
Starting Member

China
1 Posts

Posted - 08/09/2007 :  00:22:49  Show Profile  Reply with Quote
quote:
Originally posted by afrika

open the access file, then click open or Ctrl + O

then in the file types choose ODBC connection and point it to your SQL server app and corresponding table
Afrika


Is it right?I use the method, just create a new access file and quote several tables from my sqlserver."Point it to your SQL server app and corresponding table",what do yo mean,Should I point the file to what?I confused.
This topic ask how to access data from Ms-Access using Sql in Sql server.Do you reverse the intention?

---------
yuemb
Best Regards
Go to Top of Page

Arghknork
Starting Member

1 Posts

Posted - 09/04/2007 :  16:51:51  Show Profile  Send Arghknork an ICQ Message  Click to see Arghknork's MSN Messenger address  Send Arghknork a Yahoo! Message  Reply with Quote
quote:
Originally posted by Plotin

Just tried OpenRowSet but returned the following error

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. Authentication failed.
[OLE/DB provider returned message: Cannot start your application. The workgroup information file is missing or opened exclusively by another user.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80040e4d: Authentication failed.].

Here is the T-SQL statement used

SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'c:\MKBD.mdb';'admin';'mypwd', ArticleID)

Does someone know what to do?



Plotin



The problem is your Access password on that database probably isn't 'mypswd'. If you have a password on the database, put your own in there, if not use this command ...

SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'c:\MKBD.mdb';'admin';'', ArticleID)

Phil King

Phil King
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000