简体   繁体   中英

SELECT data records from MS ACCESS database using MSSQL Server

I already successfully created a link from the other workstation and I can view all the tables from MS ACCESS database. But I can't retrieve the data from the tables using simple SELECT Statement.

SELECT * FROM [192.168.1.64].default.dbo.CHECKINOUT;

When I execute this query i got this error:

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'default'.

I also found this query:

EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

SELECT a.*
FROM OPENROWSET('SQLNCLI', 'Server=192.168.1.64;Trusted_Connection=yes;',
     'SELECT *
      FROM default.dbo.CHECKINOUT') AS a;
GO

but got this error:

Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.
Configuration option 'Ad Hoc Distributed Queries' changed from 1 to 1. Run the RECONFIGURE statement to install.
OLE DB provider "SQLNCLI10" for linked server "(null)" returned message "Login timeout expired".
OLE DB provider "SQLNCLI10" for linked server "(null)" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".
Msg 1231, Level 16, State 1, Line 0
Named Pipes Provider: Could not open a connection to SQL Server [1231]. 

配置的链接服务器

When creating a Linked Server in SQL Server that points to an Access database we refer to a specific database file, so "catalog" and "schema" have no real meaning in that context. Therefore, when specifying an Access table as a four-part name in T-SQL we simply omit the second and third parts:

SELECT * FROM [AccessLinkedServerName]...[TableName]

or, in your case

SELECT * FROM [192.168.1.64]...[CHECKINOUT]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM