Connection attributes

The following tables define all possible ODBC connection attributes for the FreeTDS ODBC driver. Which ones you'll need depends on how you set yourself up. They may appear in your connection string, or in odbc.ini.

Table 4.1. Connection attributes used only in connection strings

NamePossible ValuesDefaultMeaning
DSNA valid DSN entrynoneThe DSN to which FreeTDS should connect. FreeTDS will search odbc.ini for entry. It lets you specify a connection as for SQLConnect, but using SQLDriverConnect. Do not use Servername and DSN together.
UIDAny valid usernamenoneThe username to be used when connecting. To use domain authentication, specify the domain using the format domain\username.
PWDAnyemptyThe password to be used when connecting.
WSIDAnyComputer nameThe name of the local computer, sent to server. Can be specified only for a DSN-less connection.
DateTimeFmtstrftime(3) format, %z for fractions of seconds%Y-%m-%d %H:%M:%S.%zFormat used to convert datetime, datetime2 and similar types to character. Can also be set with the SQL_COPT_TDSODBC_DATETIME_FORMAT connection attribute (see odbcss.h). A precision can be specified for fractions of seconds, for instance %3z for milliseconds.
DateFmtas above%Y-%m-%dFormat used to convert date to character. Can also be set with the SQL_COPT_TDSODBC_DATE_FORMAT connection attribute.
TimeFmtas above%H:%M:%S.%zFormat used to convert time to character. Can also be set with the SQL_COPT_TDSODBC_TIME_FORMAT connection attribute.


Table 4.2. Connection attributes that may appear in odbc.ini

NamePossible ValuesDefaultMeaning
ServernameA valid freetds.conf server sectionnoneA freetds.conf servername, not a hostname as known to DNS. If you want to use ODBC-only configuration, use Server instead.
ServerA server name or (ip) addressnoneHostname of a server. Used in an ODBC-only configuration. To specify a Microsoft SQL Server instance, use the form server\instance.
PortAny TCP portDepends on the TDS version specified with configureThe TCP port where the servername is listening.
TDS_VersionAny valid protocol versionDepends on the TDS version specified with configureTDS protocol version to use (e.g., 5.0, 7.4).
ClientCharset or Client_CharsetA name recognized by the iconv library linked to FreeTDS. Corresponds to client charset in freetds.conf. Client_Charset is for compatibility with NCBI C++ ToolKit.ISO 8859-1Character set (encoding) used by the client.
APPFree form text, up to 30 characters. noneApplication name. Identifies the connecting application to the server.
LanguageAnyus_english(Human) language the server should use for error messages.
AddressAnynoneIP address of the servername. Useful if you want to specify a server by address, rather than by name. The format is ip,port or simply ip in standard dotted-decimal notation.
DatabaseAnynoneSpecify which database you want to access. If the database does not exist or the user lacks permission to access it, the connection will fail.
TextSizeAnyServer-dependentMaximum size returned from server for blobs.
PacketSizeAnyServer-dependentSize of packets to server. Some users saw some performance gain by increasing this value. Normally you shouldn't set it.
Trusted_ConnectionYes/NoNoUse your current account instead of UID/PWD attributes. This option require SSPI or Kerberos and supersedes any UID/PWD attributes passed from the application.
Encryptionoff/request/require/strictoffSpecify encryption. See encryption on freetds.conf
Encryptyes/no/true/false/optional/mandatory/strictoptionalSpecify encryption. Similar to encryption on freetds.conf but Microsoft compatible.
ServerCertificateAnynoneFile that holds root certificates (in PEM format) to verify server certificate, used during an encrypted connection. If not specify or empty any certificate will be accepted from server. If you specify system FreeTDS will use system wide certificate list. If a certificate is not installed server can generate a self signed certificate, in this case is useful to disable certificate validation (which is the default). Note that is not possible to specify a directory as usually database servers does not use a certificate signed by a public global certification authority. Microsoft compatible.
HostNameInCertificateServer namenullServer name to match certificate name. Microsoft compatible.
MARS_ConnectionYes/NoNoEnable MARS for this connection.
UseNTLMv2Yes/NoYesUse NTLMv2 instead of normal NTLM. Disable this option if your Windows domain have this setting.
REALMMachine domainnoneKerberos REALM.
ServerSPNAny valid SPNMSSQLSvc/server FQDN:port or MSSQLSvc/server FQDN:instanceFull server Kerberos SPN. See SPN on freetds.conf.
AttachDbFilenameserver filename (mdf/sdf)noneMSSQL allow to attach a database while connecting to a server. This setting allow to do it. You should specify Database attribute to set the name of the database that will be used.
DumpFileAny File name where to dump logs.
DumpFileAppendYes/NoNoAppend to dump file instead of overwriting it.
DebugFlagsAny Debug flags. See freetds.conf entries.
ApplicationIntentReadWrite/ReadOnlyReadWriteTell application intent. See read-only intent on freetds.conf.
TimeoutInteger number Query timeout in seconds.
ConnectionTimeoutInteger number Connection timeout in seconds.