Querying a Microsoft SQL Server linked table with SAS/ACCESS® Interface to ODBC


To query a Microsoft SQL Server table on a linked server with SAS/ACCESS® Interface to ODBC, you need to use pass-through statements in the SQL procedure similar to those shown in the following example. You must also specify the full, four-part table name in the query that accesses the table.

proc sql;
connect to odbc (dsn=MS-SQL-Server-dsn user=SQL-user pwd=SQL-password);
create table test as
select * from connection to odbc
(select *
from level1-name.level2-name.level3-name.level4-name
where some_condition);
disconnect from odbc;
quit;

You can use these same PROC SQL pass-through statements when you use SAS/ACCESS® Interface to OLE DB to query a linked table.