Home » connectionstring sql server versions supported

connectionstring sql server versions supported

sql server DBA 999

Table of Contents

Connectionstring sql server versions supported

Microsoft SqlClient Data Provider for connectionstring SQL Server
Standard Security

Server=myServerAddress;Database=DatabaseName;User Id=UserName;Password=Password;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005, SQL Server 2000, SQL Server 7.0

Trusted Connection
Server=myServerAddress;Database=DatabaseName;Trusted_Connection=True;

Connection to a SQL Server instance using connectionstring SQL Server

The server/instance name syntax used in the server option is the same for all SQL Server connection strings.

Server=ServerName\InstanceName;Database=DatabaseName;User Id=UserName;Password=Password;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server on a non-standard port

If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Server=ServerName,myPortNumber;Database=DatabaseName;User Id=UserName;Password=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Using an IP address

Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=DatabaseName;User ID=UserName;Password=Password;
DBMSSOCN=TCP/IP is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server. Read more here.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server using MARS

Server=myServerAddress;Database=DatabaseName;Trusted_Connection=True;MultipleActiveResultSets=true;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005

SQL Server instance using connectionstring SQL Server Attach a database file on connect to a local SQL Server Express instance

Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;Trusted_Connection=Yes;
If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005

SQL Server instance using connectionstring SQL Server Attach a database file, located in the data directory a local SQL Server Express instance

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server LocalDB automatic instance

Server=(localdb)\v11.0;Integrated Security=true;
The first connection to LocalDB will create and start the instance, this takes some time and might cause a connection timeout failure. If this happens, wait a bit and connect again.
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server LocalDB automatic instance with specific data file

Server=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\MyFolder\MyData.mdf;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server LocalDB named instance

To create a named instance, use the SqlLocalDB.exe program.

Server=(localdb)\MyInstance;Integrated Security=true;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL ServerLocalDB named instance via the named pipes pipe name

The Server=(localdb) syntax is not supported by .NET framework versions before 4.0.2. However the named pipes connection will work to connect pre 4.0.2 applications to LocalDB instances.

Server=np:\\.\pipe\LOCALDB#F365A78E\tsql\query;
Executing SqlLocalDB.exe info MyInstance will get you (along with other info) the instance pipe name such as “np:\\.\pipe\LOCALDB#F365A78E\tsql\query”.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server LocalDB shared instance
Both automatic and named instances of LocalDB can be shared.

Server=(localdb)\.\MyInstanceShare;Integrated Security=true;
Use SqlLocalDB.exe to share or unshare an instance. For example execute SqlLocalDB.exe share “MyInstance” “MyInstanceShare” to share an instance.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server  Database mirroring

If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial Catalog=DatabaseName;Integrated Security=True;
There is of course many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality. You can combine this with the other connection strings options available.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Asynchronous processing

A connection to SQL Server that allows for the issuing of async requests through ADO.NET objects.

Server=myServerAddress;Database=DatabaseName;Integrated Security=True;Asynchronous Processing=True;
See also the List of all SqlConnection connection string properties

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Using an User Instance on a local SQL Server Express instance

The User Instance functionality creates a new SQL Server instance on the fly during connect. This works only on a local SQL Server instance and only when connecting using windows authentication over local named pipes. The purpose is to be able to create a full rights SQL Server instance to a user with limited administrative rights on the computer.

Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;User Instance=true;
To use the User Instance functionality you need to enable it on the SQL Server. This is done by executing the following command: sp_configure ‘user instances enabled’, ‘1’. To disable the functionality execute sp_configure ‘user instances enabled’, ‘0’.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL ServerSpecifying packet size

Server=myServerAddress;Database=DatabaseName;User ID=UserName;Password=Password;Trusted_Connection=False;Packet Size=4096;
By default, the Microsoft .NET Framework Data Provider for SQL Server sets the network packet size to 8192 bytes. This might however not be optimal, try to set this value to 4096 instead. The default value of 8192 might cause Failed to reserve contiguous memory errors as well, read more here.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Always Encrypted

Data Source=myServer;Initial Catalog=myDB;Integrated Security=true;Column Encryption Setting=enabled;
This one is available in .NET Core (as opposed to System.Data.SqlClient).

SQL Server 2019, SQL Server 2017, SQL Server 2016

Connection to a SQL Server instance using connectionstring SQL Server Azure SQL Database

Always Encrypted with secure enclaves
Data Source=myServer;Initial Catalog=myDB;Integrated Security=true;Column Encryption Setting=enabled;Enclave Attestation Url=http://hgs.bastion.local/Attestation;
This one is available in .NET Core (as opposed to System.Data.SqlClient).

Microsoft OLE DB Driver for SQL Server Standard security

Provider=MSOLEDBSQL;Server=myServerAddress;Database=DatabaseName;UID=UserName;PWD=Password;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server ADO to map new data types

For ADO to correctly map SQL Server new datatypes, i.e. XML, UDT, varchar(max), nvarchar(max), and varbinary(max), include DataTypeCompatibility=80; in the connection string. If you are not using ADO this is not necessary.

Provider=MSOLEDBSQL;DataTypeCompatibility=80;Server=myServerAddress;Database=DatabaseName;UID=UserName;PWD=Password;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012
Trusted connection
Provider=MSOLEDBSQL;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server connecting to an SQL Server instance
The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server. omit portnumber if default

Provider=MSOLEDBSQL;Server=ServerName\theInstanceName,myPortNumber;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

The default SQL Server port is 1433 and there is no need to specify that in the connection string.

Connection to a SQL Server instance using connectionstring SQL Server using  MARS

Provider=MSOLEDBSQL;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;MARS Connection=true;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Provider=MSOLEDBSQL;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;Encrypt=yes;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file on connect to a local SQL Server Express instance

Provider=MSOLEDBSQL;Server=.\SQLExpress;AttachDBFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Provider=MSOLEDBSQL;Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial Catalog=DatabaseName;Integrated Security=True;
There is ofcourse many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality. You can combine this with the other connection strings options available.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server Availability group and failover cluster

Enable fast failover for Always On Availability Groups and Failover Cluster Instances. TCP is the only supported protocol. Also set an explicit timeout as these scenarios might require more time.

Provider=MSOLEDBSQL;Server=tcp:AvailabilityGroupListenerDnsName,1433;MultiSubnetFailover=Yes;Database=MyDB;Integrated Security=SSPI;Connect Timeout=30;
MultiSubnetFailover will perform retries in parallell and do it faster than default TCP retransmit intervals. This can not be combined with mirroring, e.g. Failover_Partner=mirrorServer.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server Read-Only application intent

Use a read workload when connecting. Enforces read only at connection time, and also for USE database statements.

Provider=MSOLEDBSQL;Server=tcp:AvailabilityGroupListenerDnsName,1433;MultiSubnetFailover=Yes;ApplicationIntent=ReadOnly;Database=MyDB;Integrated Security=SSPI;Connect Timeout=30;
The result of using ApplicationIntent depends on database configuration. See read-only routing. The default for ApplicationIntent is ReadWrite.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server Read-Only routing

You can either use an availability group listener for Server OR the read-only instance name to enforce a specific read-only instance.

Provider=MSOLEDBSQL;Server=aKnownReadOnlyInstance;MultiSubnetFailover=Yes;ApplicationIntent=ReadOnly;Database=MyDB;Integrated Security=SSPI;Connect Timeout=30;
An availability group must enable read-only routing for this to work.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Connection to a SQL Server instance using connectionstring SQL Server SQL Server Native Client 11.0 OLE DB Provider

Standard security
Provider=SQLNCLI11;Server=myServerAddress;Database=DatabaseName;Uid=UserName;Pwd=Password;
Are you using SQL Server 2012 Express? Don’t miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2012 Express installation resides.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Trusted connection
Provider=SQLNCLI11;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Connecting to an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Provider=SQLNCLI11;Server=ServerName\theInstanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2012, SQL Server 2008, SQL Server 2005

Using a non-standard port
If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Provider=SQLNCLI11;Server=ServerName,myPortNumber;Database=DatabaseName;Uid=UserName;Pwd=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server using MARS

Provider=SQLNCLI11;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;MARS Connection=True;
SQL Server 2012,SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Provider=SQLNCLI11;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;Encrypt=yes;
SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file on connect to a local SQL Server Express instance

Provider=SQLNCLI11;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file, located in the data directory, on connect to a local SQL Server Express instance

Provider=SQLNCLI11;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Provider=SQLNCLI11;Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial Catalog=DatabaseName;Integrated Security=True;
There is ofcourse many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality. You can combine this with the other connection strings options available.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server SQL Server Native Client 10.0 OLE DB Provider

Standard security
Provider=SQLNCLI10;Server=myServerAddress;Database=DatabaseName;Uid=UserName;Pwd=Password;
Are you using SQL Server 2008 Express? Don’t miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2008 Express installation resides.

SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Trusted connection
Provider=SQLNCLI10;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Connecting to an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Provider=SQLNCLI10;Server=ServerName\theInstanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Using a non-standard port
If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Provider=SQLNCLI10;Server=ServerName,myPortNumber;Database=DatabaseName;Uid=UserName;Pwd=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server using MARS

Provider=SQLNCLI10;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;MARS Connection=True;
SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Provider=SQLNCLI10;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;Encrypt=yes;
SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file on connect to a local SQL Server Express instance

Provider=SQLNCLI10;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file, located in the data directory on local SQL Server Express instance

Provider=SQLNCLI10;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Provider=SQLNCLI10;Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial Catalog=DatabaseName;Integrated Security=True;
There is ofcourse many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality. You can combine this with the other connection strings options available.

SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server SQL Native Client 9.0 OLE DB Provider

Standard security
Provider=SQLNCLI;Server=myServerAddress;Database=DatabaseName;Uid=UserName;Pwd=Password;
Are you using SQL Server 2005 Express? Don’t miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2005 Express installation resides.

SQL Server 2005, SQL Server 2000, SQL Server 7.0

Trusted connection
Provider=SQLNCLI;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: “Integrated Security=SSPI” equals “Trusted_Connection=yes”

SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Connecting to an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Provider=SQLNCLI;Server=ServerName\theInstanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Using a non-standard port

If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Provider=SQLNCLI;Server=ServerName,myPortNumber;Database=DatabaseName;Uid=UserName;Pwd=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server using MARS

Provider=SQLNCLI;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;MARS Connection=True;
SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Provider=SQLNCLI;Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;Encrypt=yes;

SQL Server 2005, SQL Server 2000,SQL Server 7.0

 

Connection to a SQL Server instance using connectionstring SQL Server  .NET Framework Data Provider for OLE DB

Use an OLE DB provider from .NET
Provider=any oledb provider's name;OledbKey1=someValue;OledbKey2=someValue;
See the respective OLEDB provider’s connection strings options. The .net OleDbConnection will just pass on the connection string to the specified OLEDB provider. Read more here.

Connection to a SQL Server instance using connectionstring SQL Server Microsoft ODBC Driver 17 for SQL Server

Standard security
Driver={ODBC Driver 17 for SQL Server};Server=myServerAddress;Database=DatabaseName;UID=UserName;PWD=Password;
Using SQL Server Express? The server name syntax is ServerName\SQLEXPRESS where you substitute ServerName with the name of the server where SQL Server Express is running.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012
SQL Server 2008

Trusted Connection
Driver={ODBC Driver 17 for SQL Server};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012
SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Connecting to an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Driver={ODBC Driver 17 for SQL Server};Server=serverName\instanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012
SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Using a non-standard port

If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Driver={ODBC Driver 17 for SQL Server};Server=ServerName,myPortNumber;Database=DatabaseName;UID=UserName;PWD=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012
SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server using  MARS

Driver={ODBC Driver 17 for SQL Server};Server=serverAddress;Database=databaseName;Trusted_Connection=yes;MARS_Connection=yes;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012
SQL Server 2008

 

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Driver={ODBC Driver 17 for SQL Server};Server=serverAddress;Database=databaseName;Trusted_Connection=yes;Encrypt=yes;
SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012
SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file on connect to a local SQL Server Express instance

Driver={ODBC Driver 17 for SQL Server};Server=.\SQLExpress;AttachDBFileName=c:\dir\\mydb.mdf;Database=dbName;Trusted_Connection=yes;
If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012
SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Driver={ODBC Driver 17 for SQL Server};Server=myServerAddress;Failover_Partner=myMirrorServerAddress;Database=DatabaseName;Trusted_Connection=yes;

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Microsoft ODBC Driver 13 for SQL Server

Connection to a SQL Server instance using connectionstring SQL Server Standard security

Driver={ODBC Driver 13 for SQL Server};Server=myServerAddress;Database=DatabaseName;UID=UserName;PWD=Password;
The server name syntax is ServerName\SQLEXPRESS where you substitute ServerName with the name of the server where SQL Server Express is running.

SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012,SQL Server 2008

Trusted Connection
Driver={ODBC Driver 13 for SQL Server};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012,SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Connecting to an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Driver={ODBC Driver 13 for SQL Server};Server=serverName\instanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012,SQL Server 2008

Using a non-standard port
If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Driver={ODBC Driver 13 for SQL Server};Server=ServerName,myPortNumber;Database=DatabaseName;UID=UserName;PWD=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012,SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Using MARS

Driver={ODBC Driver 13 for SQL Server};Server=serverAddress;Database=databaseName;Trusted_Connection=yes;MARS_Connection=yes;
SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012,SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Driver={ODBC Driver 13 for SQL Server};Server=serverAddress;Database=databaseName;Trusted_Connection=yes;Encrypt=yes;
SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012,SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file on a local SQL Server Express instance

Driver={ODBC Driver 13 for SQL Server};Server=.\SQLExpress;AttachDBFileName=c:\dir\\mydb.mdf;Database=dbName;Trusted_Connection=yes;
If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012,SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Driver={ODBC Driver 13 for SQL Server};Server=myServerAddress;Failover_Partner=myMirrorServerAddress;Database=DatabaseName;Trusted_Connection=yes;

SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012,SQL Server 2008

Connection to a SQL Server instance using connectionstring SQL Server Microsoft ODBC Driver 11 for SQL Server

Standard security
Driver={ODBC Driver 11 for SQL Server};Server=myServerAddress;Database=DatabaseName;UID=UserName;PWD=Password;
The server name syntax is ServerName\SQLEXPRESS where you substitute ServerName with the name of the server where SQL Server Express is running.

SQL Server 2014,SQL Server 2012,SQL Server 2008,SQL Server 2005

Trusted Connection
Driver={ODBC Driver 11 for SQL Server};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

SQL Server 2014,SQL Server 2012,SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Connecting to an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Driver={ODBC Driver 11 for SQL Server};Server=serverName\instanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2014,SQL Server 2012,SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Using a non-standard port

If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Driver={ODBC Driver 11 for SQL Server};Server=ServerName,myPortNumber;Database=DatabaseName;UID=UserName;PWD=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2014,SQL Server 2012,SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server using MARS

Driver={ODBC Driver 11 for SQL Server};Server=serverAddress;Database=databaseName;Trusted_Connection=yes;MARS_Connection=yes;
SQL Server 2014,SQL Server 2012,SQL Server 2008,SQL Server 2005
Encrypt data sent over network
Driver={ODBC Driver 11 for SQL Server};Server=serverAddress;Database=databaseName;Trusted_Connection=yes;Encrypt=yes;


SQL Server 2014,SQL Server 2012,SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server

Attach a database file on connect to a local SQL Server Express instance
Driver={ODBC Driver 11 for SQL Server};Server=.\SQLExpress;AttachDBFileName=c:\dir\\mydb.mdf;Database=dbName;Trusted_Connection=yes;


If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2014,SQL Server 2012,SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Driver={ODBC Driver 11 for SQL Server};Server=myServerAddress;Failover_Partner=myMirrorServerAddress;Database=DatabaseName;Trusted_Connection=yes;

SQL Server 2014,SQL Server 2012,SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server SQL Server Native Client 11.0 ODBC Driver

Standard security
Driver={SQL Server Native Client 11.0};Server=myServerAddress;Database=DatabaseName;Uid=UserName;Pwd=Password;

Are you using SQL Server 2012 Express then use server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2012 Express installation resides.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Trusted Connection
Driver={SQL Server Native Client 11.0};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Connecting to an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Driver={SQL Server Native Client 11.0};Server=ServerName\theInstanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2012, SQL Server 2008,SQL Server 2005

Using a non-standard port
If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Driver={SQL Server Native Client 11.0};Server=ServerName,myPortNumber;Database=DatabaseName;Uid=UserName;Pwd=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server using MARS

Driver={SQL Server Native Client 11.0};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;MARS_Connection=yes;
SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Driver={SQL Server Native Client 11.0};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;Encrypt=yes;
SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file on connect to a local SQL Server Express instance

Driver={SQL Server Native Client 11.0};Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file, located in the data directory on a local SQL Server Express instance

Driver={SQL Server Native Client 11.0};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Driver={SQL Server Native Client 11.0};Server=myServerAddress;Failover_Partner=myMirrorServerAddress;Database=DatabaseName;Trusted_Connection=yes;

SQL Server 2012, SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server SQL Server Native Client 10.0 ODBC Driver

Standard security
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=DatabaseName;Uid=UserName;Pwd=Password;
Are you using SQL Server 2008 Express? Don’t miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2008 Express installation resides.

SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Trusted Connection
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: “Integrated Security=SSPI” equals “Trusted_Connection=yes”

SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Connecting to an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Driver={SQL Server Native Client 10.0};Server=ServerName\theInstanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0
Using a non-standard port
If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Driver={SQL Server Native Client 10.0};Server=ServerName,myPortNumber;Database=DatabaseName;Uid=UserName;Pwd=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server using MARS

Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;MARS_Connection=yes;
SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;Encrypt=yes;
SQL Server 2008,SQL Server 2005,SQL Server 2000,SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server

Attach a database file on connect to a local SQL Server Express instance
Driver={SQL Server Native Client 10.0};Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Attach a database file, located in the data directory on local SQL Server Express instance

Driver={SQL Server Native Client 10.0};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Driver={SQL Server Native Client 10.0};Server=myServerAddress;Failover_Partner=myMirrorServerAddress;Database=DatabaseName;Trusted_Connection=yes;

SQL Server 2008, SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server SQL Native Client 9.0 ODBC Driver

Standard security
Driver={SQL Native Client};Server=myServerAddress;Database=DatabaseName;Uid=UserName;Pwd=Password;
Are you using SQL Server 2005 Express? Don’t miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2005 Express installation resides.

SQL Server 2005,SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Trusted Connection

Driver={SQL Native Client};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server too an SQL Server instance

The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Driver={SQL Native Client};Server=ServerName\theInstanceName;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2005, SQL Server 2000,SQL Server 7.0

Using a non-standard port
If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Driver={SQL Native Client};Server=ServerName,myPortNumber;Database=DatabaseName;Uid=UserName;Pwd=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server using MARS

Driver={SQL Native Client};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;MARS_Connection=yes;
SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Encrypt data sent over network

Driver={SQL Native Client};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=yes;Encrypt=yes;
SQL Server 2005, SQL Server 2000, SQL Server 7.0

Attach a database file on connect to a local SQL Server Express instance

Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2005

Attach a database file, located in the data directory, on connect to a local SQL Server Express instance

Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Database mirroring

If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Driver={SQL Server Native Client 10.0};Server=myServerAddress;Failover_Partner=myMirrorServerAddress;Database=DatabaseName;Trusted_Connection=yes;
SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Microsoft SQL Server ODBC Driver

Connection to a SQL Server instance using connectionstring SQL Server Standard Security

Driver={SQL Server};Server=myServerAddress;Database=DatabaseName;Uid=UserName;Pwd=Password;
SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Trusted connection

Driver={SQL Server};Server=myServerAddress;Database=DatabaseName;Trusted_Connection=Yes;
SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Using a non-standard port

If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it’s not a colon).

Driver={SQL Server};Server=ServerName,myPortNumber;Database=DatabaseName;Uid=UserName;Pwd=Password;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server .NET Framework Data Provider for ODBC

Use an ODBC driver from .NET
Driver={any odbc driver's name};OdbcKey1=someValue;OdbcKey2=someValue;
See the respective ODBC driver’s connection strings options. The .net OdbcConnection will just pass on the connection string to the specified ODBC driver. Read more here.

Connection to a SQL Server instance using connectionstring SQL Server SQLXML 4.0 OLEDB Provider

With Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL)
The DataTypeCompatibility=80 is important for the XML types to be recognised by ADO.

Provider=SQLXMLOLEDB.4.0;Data Provider=MSOLEDBSQL;DataTypeCompatibility=80;Data Source=myServerAddress;Initial Catalog=DatabaseName;User Id=UserName;Password=Password;
See also the other options available for MSOLEDBSQL connection strings.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012

Using SQL Server Native Client provider 11 (SQLNCLI11)
Provider=SQLXMLOLEDB.4.0;Data Provider=SQLNCLI11;Data Source=myServerAddress;Initial Catalog=DatabaseName;User Id=UserName;Password=Password;
SQL Server 2012

Using SQL Server Native Client provider 10 (SQLNCLI10)
Provider=SQLXMLOLEDB.4.0;Data Provider=SQLNCLI10;Data Source=myServerAddress;Initial Catalog=DatabaseName;User Id=UserName;Password=Password;
SQL Server 2008

Using SQL Server Native Client provider (SQLNCLI)
Provider=SQLXMLOLEDB.4.0;Data Provider=SQLNCLI;Data Source=myServerAddress;Initial Catalog=DatabaseName;User Id=UserName;Password=Password;
SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server SQLXML 3.0 OLEDB Provider

Using SQL Server Ole Db
The SQLXML version 3.0 restricts the data provider to SQLOLEDB only.

Provider=SQLXMLOLEDB.3.0;Data Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=DatabaseName;User Id=UserName;Password=Password;
SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Asynchronous processing

A connection to SQL Server that allows for the issuing of async requests through ADO.NET objects.

Server=myServerAddress;Database=DatabaseName;Integrated Security=True;Asynchronous Processing=True;
See also the List of all SqlConnection connection string properties

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005

Connection to a SQL Server instance using connectionstring SQL Server Using an User Instance on a local SQL Server Express instance

The User Instance functionality creates a new SQL Server instance on the fly during connect. This works only on a local SQL Server instance and only when connecting using windows authentication over local named pipes. The purpose is to be able to create a full rights SQL Server instance to a user with limited administrative rights on the computer.

Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;User Instance=true;
To use the User Instance functionality you need to enable it on the SQL Server. This is done by executing the following command: sp_configure ‘user instances enabled’, ‘1’. To disable the functionality execute sp_configure ‘user instances enabled’, ‘0’.

SQL Server 2019,SQL Server 2017,SQL Server 2016,SQL Server 2014
Specifying packet size
Server=myServerAddress;Database=DatabaseName;User ID=UserName;Password=Password;Trusted_Connection=False;Packet Size=4096;
By default, the Microsoft .NET Framework Data Provider for SQL Server sets the network packet size to 8192 bytes. This might however not be optimal, try to set this value to 4096 instead. The default value of 8192 might cause Failed to reserve contiguous memory errors as well, read more here.

SQL Server 2019, SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008,SQL Server 2005, SQL Server 2000, SQL Server 7.0

Connection to a SQL Server instance using connectionstring SQL Server Always Encrypted

Data Source=myServer;Initial Catalog=myDB;Integrated Security=true;Column Encryption Setting=enabled;
This one is available in .NET Core (as opposed to System.Data.SqlClient).

SQL Server 2019, SQL Server 2017, SQL Server 2016

Connection to a SQL Server instance using connectionstring SQL Server Azure SQL Database

Always Encrypted with secure enclaves
Data Source=myServer;Initial Catalog=myDB;Integrated Security=true;Column Encryption Setting=enabled;Enclave Attestation Url=http://hgs.bastion.local/Attestation;
This one is available in .NET Core (as opposed to System.Data.SqlClient).

SQL Server 2019

 

Leave a Reply

Your email address will not be published. Required fields are marked *