Connection String Generator for SQL Server

The most complete connection string builder for SQL Server

Basic Settings

Valid port numbers are between 0 and 65535.
The database name can be 128 characters or less.
An application name can be 128 characters or less.
Valid values are greater than or equal to 0 and less than or equal to 2147483647.
The user ID must be 128 characters or less.
The password must be 128 characters or less.
Valid values are greater than or equal to 0 and less than or equal to 255.
Valid values are greater than or equal to 0 and less than or equal to 60.
The server name can be 128 characters or less.
Valid values are greater than or equal to 0.
Valid values are greater than or equal to 1.
The ID must be 128 characters or less.

Keywords Explained with Synonyms

Keyword
Default
Description
Application Name
App
N/A

The application name identifies the specific application accessing the database.

If no application name is provided, it defaults to .NET SQLClient Data Provider.

ApplicationIntent ReadWrite

Determines the intended workload type for the application when connecting to the server.

For more information on SqlClient support for Always On Availability Groups, see SqlClient Support for High Availability, Disaster Recovery.

Asynchronous Processing
Async
false

Setting this to true enables support for asynchronous operations.

AttachDBFilename
Extended Properties
Initial File Name
N/A

Specifies the primary database's file name, including the full path of an attachable database. Only applicable for primary data files with a .mdf extension.

When the AttachDBFileName key is in the connection string, the specified database is attached and becomes the default for the connection.

If this key isn't specified and the database was previously attached, the previously attached database remains as the default.

If both the AttachDBFileName key and this key are specified together, this key's value acts as the alias. However, if the name is already used in another attached database, the connection fails.

The path can be absolute or relative using the DataDirectory substitution string. Note that remote server, HTTP, and UNC path names aren't supported.

The database name must be specified with the keyword Database (or one of its aliases) in the connection string.

An error occurs if a log file exists in the same directory as the data file when attaching the primary data file. In such cases, remove the log file. Once the database is attached, a new log file is automatically generated based on the physical path.

Authentication
Extended Properties
Initial File Name
N/A

The authentication method determines how to connect to SQL Database using Azure Active Directory Authentication.

Column Encryption Setting
N/A

Enables or disables Always Encrypted functionality for the connection.

Connect Timeout
Connection Timeout
Timeout
15

The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.

Connection Lifetime
Load Balance Timeout
0

When a connection is returned to the pool, its creation time is compared with the current time. If the time span (in seconds) exceeds the value specified by Connection Lifetime, the connection is destroyed. This is useful in clustered configurations to force load balancing between a running server and a server just brought online.

A value of zero (0) sets pooled connections to have the maximum connection timeout.

ConnectRetryCount
1

Controls the number of reconnection attempts after the client identifies an idle connection failure. Setting it to 0 disables connection resiliency.

For additional information about connection resiliency, see SqlConnection parameters for connection retry and Technical Article - Idle Connection Resiliency.

ConnectRetryInterval
10

Specifies the time between each connection retry attempt (ConnectRetryCount), applied after the first reconnection attempt. When a broken connection is detected, the client immediately attempts to reconnect; this is the first reconnection attempt and only occurs if ConnectRetryCount is greater than 0.

If the first reconnection attempt fails and ConnectRetryCount is greater than 1, the client waits ConnectRetryInterval to try the second and subsequent reconnection attempts.

For additional information about connection resiliency, see SqlConnection parameters for connection retry and Technical Article - Idle Connection Resiliency.

Context Connection
false

Indicates whether to establish an in-process connection to SQL Server. When set to true, a connection is made directly within the executing process, enabling the application or service to interact with the SQL Server database without involving external processes or intermediaries.

Current Language
Language
N/A

Sets the language used for database server warning or error messages.

Data Source
Server
Address
Addr
Network Address
N/A

Specifies the name or network address of the SQL Server instance to connect to. The port number can be specified after the server name. The Data Source field must use either the TCP or Named Pipes format.

Encrypt
false

Enables SSL encryption for data transmitted between the client and server if the server has a certificate installed. Recognized values are true, false, yes, and no. For more details, refer to the Connection String Syntax.

Starting from .NET Framework 4.5, when TrustServerCertificate is false and Encrypt is true, the server name (or IP address) in a SQL Server SSL certificate must precisely match the server name (or IP address) specified in the connection string. Failure to match will result in a connection failure.

Enlist
true

When set to true, it indicates that the SQL Server connection pooler automatically enlists the connection in the creation thread's current transaction context.

Failover Partner
N/A

Specifies the name of the failover partner server where database mirroring is configured. If this key is set to an empty string, then the Initial Catalog must be present and not empty.

If you specify a failover partner but the server is not configured for database mirroring and the primary server is unavailable, the connection will fail.

If you specify a failover partner and the primary server is not configured for database mirroring, the connection to the primary server will succeed if it's available.

Database
Initial Catalog
N/A

Specifies the name of the database.

Integrated Security
Trusted_Connection
false

When set to false, specifies that the User ID and Password are provided in the connection. When set to 'true', the current Windows account credentials are used for authentication.

Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true.

If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored, and Integrated Security will be used.

SqlCredential provides a more secure way to specify credentials for a connection using SQL Server Authentication (Integrated Security=false).

Max Pool Size
100

Specifies the maximum number of connections allowed in the pool.

Values less than Min Pool Size will result in an error.

Min Pool Size
0

Specifies the minimum number of connections allowed in the pool. Zero (0) means no minimum connections are initially opened.

Values greater than Max Pool Size will result in an error.

MultipleActiveResultSets
false

When set to true, an application can maintain multiple active result sets (MARS). When set to false, an application must process or cancel all result sets from one batch before it can execute any other batch on that connection.

MultiSubnetFailover
false

Always specify multiSubnetFailover=True when connecting to the availability group listener of a SQL Server 2012 (or later) availability group or a SQL Server 2012 (or later) Failover Cluster Instance.

multiSubnetFailover=True configures SqlClient to provide faster detection of and connection to the (currently) active server.

Network Library
Network
Net
N/A

Specifies the network library used to establish a connection to an instance of SQL Server.

Packet Size
8000

Size in bytes of the network packets used to communicate with an instance of SQL Server. The packet size can be between 512 and 32768 bytes.

Password
PWD
N/A

The password for the SQL Server account logging on. Not recommended for maintaining high security. Instead, we strongly recommend using the Integrated Security or Trusted_Connection keyword.

SqlCredential provides a more secure way to specify credentials for a connection using SQL Server Authentication.

Persist Security Info
PersistSecurityInfo
false

When set to false or no (strongly recommended), security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values, including the password.

Pool Blocking Period
Auto

Sets the blocking period behavior for a connection pool. When connection pooling is enabled and a timeout error or other login error occurs, an exception will be thrown and subsequent connection attempts will fail for the next five seconds, the "blocking period".

If the application attempts to connect within the blocking period, the first exception will be thrown again. Subsequent failures after a blocking period ends will result in a new blocking period that is twice as long as the previous blocking period, up to a maximum of one minute.

PoolBlockingPeriod enables you to select the blocking period best suited for your app.

Pooling
true

When set to true, any newly created connection will be added to the pool when closed by the application. In the next attempt to open the same connection, it will be drawn from the pool.

Connections are considered the same if they have the same connection string. Different connections have different connection strings.

Replication
false

When set to true, indicates that replication is supported using the connection.

Transaction Binding
Implicit Unbind

Controls connection association with an enlisted System.Transactions transaction.

Implicit Unbind causes the connection to detach from the transaction when it ends. After detaching, additional requests on the connection are performed in autocommit mode. The System.Transactions.Transaction.Current property is not checked when executing requests while the transaction is active. After the transaction has ended, additional requests are performed in autocommit mode. If the system ends the transaction (in the scope of a using block) before the last command completes, it will throw InvalidOperationException.

Explicit Unbind causes the connection to remain attached to the transaction until the connection is closed or an explicit SqlConnection.TransactionEnlist(null) is called. Beginning in .NET Framework 4, changes to Implicit Unbind make Explicit Unbind obsolete. An InvalidOperationException is thrown if Transaction.Current is not the enlisted transaction or if the enlisted transaction is not active.

Transparent Network IP Resolution
See description

When set to true, the application retrieves all IP addresses for a particular DNS entry and attempts to connect with the first one in the list. If the connection is not established within 0.5 seconds, the application tries to connect to all others in parallel. When the first answers, the application establishes the connection with the respondent IP address.

If MultiSubnetFailover or Failover Partner keys are set, TransparentNetworkIPResolution is ignored.

Default values are:

  • false when connecting to Azure SQL Database with specific endings or using Active Directory Password/Integrated Authentication.
  • true in all other cases.

Trust Server Certificate
false

When set to true, SSL is used to encrypt the channel when bypassing walking the certificate chain to validate trust. If TrustServerCertificate is set to true and Encrypt is set to false, the channel is not encrypted.

Type System Version
N/A

A string value indicating the type system the application expects. Functionality available to a client application depends on the SQL Server version and database compatibility level. Explicitly setting the type system version avoids potential problems that could cause an application to break with a different SQL Server version.

User ID
N/A

The SQL Server login account. Not recommended for maintaining security. It's strongly recommended to use Integrated Security or Trusted_Connection keywords instead.

SqlCredential provides a more secure way to specify credentials for a connection using SQL Server Authentication.

User Instance
false

A value indicating whether to redirect the connection from the default SQL Server Express instance to a runtime-initiated instance running under the account of the caller.

Workstation ID
The local computer name

The name of the workstation connecting to SQL Server.

Basic Settings

Please enter a valid port number between 0 and 65535.
The database name can be 128 characters or less.
An application name can be 128 characters or less.
Please enter a positive number.
The user ID must be 128 characters or less.
The password must be 128 characters or less.
Must be greater than 0.
Must be greater than 0.
Must be greater than 0.
Must be greater than 0.
The server name can be 128 characters or less.