Attribute values can optionally be enclosed in braces, and it is good practice to do so. This avoids problems when attribute values contain non-alphanumeric characters. The first closing brace in the value is assumed to terminate the value, so values cannot contain closing brace characters.
The following table describes the keywords that may be used with an ODBC connection string.
|
Keyword
|
Description
|
|---|
|
Addr
|
Synonym for "Address".
|
|
Address
|
The network address of the server running an instance of SQL Server. Address is usually the network name of the server, but can be other names such as a pipe, an IP address, or a TCP/IP port and socket address.
If you specify an IP address, make sure that the TCP/IP or named pipes protocols are enabled in SQL Server Configuration Manager.
The value of Address takes precedence over the value passed to Server in ODBC connection strings when using SQL Server Native Client. Also note that Address=; will connect to the server specified in the Server keyword, whereas Address= ;, Address=.;, Address=localhost;, and Address=(local); all cause a connection to the local server.
The complete syntax for the Address keyword is as follows:
[protocol:]Address[,port |\pipe\pipename]
protocol can be tcp (TCP/IP), lpc (shared memory), or np (named pipes). For more information about protocols, see Choosing a Network Protocol.
If neither protocol nor the Network keyword is specified, SQL Server Native Client will use the protocol order specified in SQL Server Configuration Manager.
port is the port to connect to, on the specified server. By default, SQL Server uses port 1433.
For more information about protocols, see Choosing a Network Protocol.
|
|
AnsiNPW
|
When "yes", the driver uses ANSI-defined behaviors for handling NULL comparisons, character data padding, warnings, and NULL concatenation. When "no", ANSI defined behaviors are not exposed. For more information about ANSI NPW behaviors, see Effects of ISO Options.
|
|
APP
|
Name of the application calling SQLDriverConnect (optional). If specified, this value is stored in the master.dbo.sysprocesses column program_name and is returned by sp_who and the APP_NAME functions.
|
|
AttachDBFileName
|
Name of the primary file of an attachable database. Include the full path and escape any \ characters if using a C character string variable:
AttachDBFileName=c:\\MyFolder\\MyDB.mdf
This database is attached and becomes the default database for the connection. To use AttachDBFileName you must also specify the database name in either the SQLDriverConnect DATABASE parameter or the SQL_COPT_CURRENT_CATALOG connection attribute. If the database was previously attached, SQL Server does not reattach it; it uses the attached database as the default for the connection.
|
|
AutoTranslate
|
When "yes", ANSI character strings sent between the client and server are translated by converting through Unicode to minimize problems in matching extended characters between the code pages on the client and the server.
Client SQL_C_CHAR data sent to a SQL Server char, varchar, or text variable, parameter, or column is converted from character to Unicode using the client ANSI code page (ACP), then converted from Unicode to character using the ACP of the server.
SQL Server char, varchar, or text data sent to a client SQL_C_CHAR variable is converted from character to Unicode using the server ACP, then converted from Unicode to character using the client ACP.
These conversions are performed on the client by the SQL Server Native Client ODBC driver. This requires that the same ANSI code page (ACP) used on the server be available on the client.
These settings have no effect on the conversions that occur for these transfers:
-
Unicode SQL_C_WCHAR client data sent to char, varchar, or text on the server.
-
char, varchar, or text server data sent to a Unicode SQL_C_WCHAR variable on the client.
-
ANSI SQL_C_CHAR client data sent to Unicode nchar, nvarchar, or ntext on the server.
-
Unicode nchar, nvarchar, or ntext server data sent to an ANSI SQL_C_CHAR variable on the client.
When "no", character translation is not performed.
The SQL Server Native Client ODBC driver does not translate client ANSI character SQL_C_CHAR data sent to char, varchar, or text variables, parameters, or columns on the server. No translation is performed on char, varchar, or text data sent from the server to SQL_C_CHAR variables on the client.
If the client and SQL Server are using different ACPs, extended characters may be misinterpreted.
|
|
Database
|
Name of the default SQL Server database for the connection. If Database is not specified, the default database defined for the login is used. The default database from the ODBC data source overrides the default database defined for the login. The database must be an existing database unless AttachDBFileName is also specified. If AttachDBFileName is also specified, the primary file it points to is attached and given the database name specified by Database.
|
|
Driver
|
Name of the driver as returned by SQLDrivers. The keyword value for the SQL Server Native Client ODBC driver is "{SQL Server Native Client 10.0}". The Server keyword is required if Driver is specified and DriverCompletion is set to SQL_DRIVER_NOPROMPT.
For more information about driver names, see Using the SQL Server Native Client Header and Library Files.
|
|
DSN
|
Name of an existing ODBC user or system data source. This keyword overrides any values that might be specified in the Server, Network, and Address keywords.
|
|
Encrypt
|
Specifies whether data should be encrypted before sending it over the network. Possible values are "yes" and "no". The default value is "no".
|
|
Fallback
|
This keyword is deprecated, and its setting is ignored by the SQL Server Native Client ODBC driver.
|
|
Failover_Partner
|
Name of the failover partner server to be used if a connection cannot be made to the primary server.
|
|
FailoverPartnerSPN
|
The SPN for the failover partner. The default value is an empty string. An empty string causes SQL Server Native Client to use the default, driver-generated SPN.
|
|
FileDSN
|
Name of an existing ODBC file data source.
|
|
Language
|
SQL Server language name (optional). SQL Server can store messages for multiple languages in sysmessages. If connecting to a SQL Server with multiple languages, Language specifies which set of messages are used for the connection.
|
|
MARS_Connection
|
Enables or disables multiple active result sets (MARS) on the connection if the server is SQL Server 2005 or SQL Server 2008. Recognized values are "yes" and "no". The default is "no".
|
|
Net
|
Synonym for "Network".
|
|
Network
|
Valid values are dbnmpntw (named pipes) and dbmssocn (TCP/IP).
For more information about network protocols, see Choosing a Network Protocol.
It is an error to specify both a value for the Network keyword and a protocol prefix on the Server keyword.
|
|
PWD
|
The password for the SQL Server login account specified in the UID parameter. PWD need not be specified if the login has a NULL password or when using Windows Authentication (Trusted_Connection = yes).
|
|
QueryLog_On
|
When "yes", logging long-running query data is enabled on the connection. When "no", long-running query data is not logged.
|
|
QueryLogFile
|
Full path and file name of a file to use to log data on long-running queries.
|
|
QueryLogTime
|
Digit character string specifying the threshold (in milliseconds) for logging long-running queries. Any query that does not get a response in the time specified is written to the long-running query log file.
|
|
QuotedId
|
When "yes", QUOTED_IDENTIFIERS is set ON for the connection, SQL Server uses the ISO rules regarding the use of quotation marks in SQL statements. When no, QUOTED_IDENTIFIERS is set OFF for the connection. SQL Server then follows the legacy Transact-SQL rules regarding the use of quotation marks in SQL statements. For more information, see Effects of ISO Options.
|
|
Regional
|
When "yes", the SQL Server Native Client ODBC driver uses client settings when converting currency, date, and time data to character data. The conversion is one way only; the driver does not recognize non-ODBC standard formats for date strings or currency values within; for example, a parameter used in an INSERT or UPDATE statement. When "no", the driver uses ODBC standard strings to represent currency, date, and time data that is converted to character data.
|
|
SaveFile
|
Name of an ODBC data source file into which the attributes of the current connection are saved if the connection is successful.
|
|
Server
|
The name of a SQL Server instance. The value must be either the name of a server on the network, an IP address, or the name of a SQL Server Configuration Manager alias.
The Address keyword overrides the Server keyword.
You can connect to the default instance on the local server by specifiying one of the following:
-
Server=;
-
Server=.;
-
Server=(local);
-
Server=(localhost);
To specify a named instance of SQL Server, append \InstanceName.
When no server is specified, a connection is made to the default instance on the local computer.
If you specify an IP address, make sure that the TCP/IP or named pipes protocols are enabled in SQL Server Configuration Manager.
The complete syntax for the Server keyword is as follows:
Server=[protocol:]Server[,port]
protocol can be tcp (TCP/IP), lpc (shared memory), or np (named pipes). For more information about protocols, see Choosing a Network Protocol.
The following is an example of specifying a named pipe:
np:\\.\pipe\MSSQL$MYINST01\sql\query
This line specifies named pipe protocol, a named pipe on the local machine (\\.\pipe), the name of the SQL Server instance (MSSQL$MYINST01), and the default name of the named pipe (sql/query).
If neither a protocol nor the Network keyword is specified, SQL Server Native Client will use the protocol order specified in SQL Server Configuration Manager.
port is the port to connect to, on the specified server. By default, SQL Server uses port 1433.
Spaces are ignored at the beginning of the value passed to Server in ODBC connection strings when using SQL Server Native Client.
|
|
ServerSPN
|
The SPN for the server. The default value is an empty string. An empty string causes SQL Server Native Client to use the default, driver-generated SPN.
|
|
StatsLog_On
|
When "yes", enables the capture of SQL Server Native Client ODBC driver performance data. When "no", SQL Server Native Client ODBC driver performance data is not available on the connection.
|
|
StatsLogFile
|
Full path and file name of a file used to record SQL Server Native Client ODBC driver performance statistics.
|
|
Trusted_Connection
|
When "yes", instructs the SQL Server Native Client ODBC driver to use Windows Authentication Mode for login validation. Otherwise instructs the SQL Server Native Client ODBC driver to use a SQL Server username and password for login validation, and the UID and PWD keywords must be specified.
|
|
TrustServerCertificate
|
When used with Encrypt, enables encryption using a self-signed server certificate.
|
|
UID
|
A valid SQL Server login account. UID need not be specified when using Windows Authentication.
|
|
UseProcForPrepare
|
This keyword is deprecated, and its setting is ignored by the SQL Server Native Client ODBC Driver.
|
|
WSID
|
The workstation ID. Typically, this is the network name of the computer on which the application resides (optional). If specified, this value is stored in the master.dbo.sysprocesses column hostname and is returned by sp_who and the HOST_NAME function.
|
The SQL Server Native Client ODBC driver uses the locale registry settings for the current user. The driver does not honor the current thread's locale if the application sets it after connection by, for example, calling SetThreadLocale.
Altering the regional behavior of a data source can cause application failure. An application that parses date strings, and expects date strings to appear as defined by ODBC, could be adversely affected by altering this value.