Examples of SAS/ACCESS® Interface to ODBC LIBNAME code used to access a Microsoft SQL Server database without configuring an ODBC data source name


When using SAS/ACCESS Interface to ODBC, it is not necessary to configure an Open Database Connectivity (ODBC) data source (DSN) to assign a library to your Microsoft SQL Server database. When you are using the SQL Server ODBC Driver, you can complete a connection without a DSN.

Here is an example:

libname mydata odbc complete="driver=SQL Server;
                              uid=user-ID;
                              pwd=password;
                              database=SQL-database;
                              Server=server-name"
                   schema=schema-name;

This example uses Windows Authentication:

libname mydata odbc complete="driver=SQL Server;
                              database=SQL-database;
                              server=server-name"
                    schema=schema-name;

When you use the Microsoft SQL Server Native Client ODBC driver, the code for a connection without a DSN is as follows:

libname mylib odbc noprompt="driver=SQL Server Native Client 10.0;
                             server=server-name;
                             uid=user-ID;
                             pwd=password
                             database=SQL-database"
                   schema=schema-name;

Or this code, using Windows Authentication:

libname mylib odbc noprompt="driver=SQL Server Native Client 10.0;
                             server=server-name;
                             database=SQL-database;
                             Trusted_Connection=yes"
                  schema=schema-name;