MSSQL (SQL Server) Connection String Format
Build a Microsoft SQL Server connection string. Covers the sqlserver:// URI, ADO.NET key-value format, Windows authentication, and encryption options.
Detailed Explanation
MSSQL Connection String Formats
Microsoft SQL Server supports two primary connection string formats: the URI format used by modern tools and the classic ADO.NET key-value format.
URI Format (Prisma, modern drivers)
sqlserver://[user[:password]@]host[:port];database=dbname[;param=value]
Example:
sqlserver://sa:MyStr0ngP%40ss@localhost:1433;database=myapp;encrypt=true
Note that MSSQL URIs use semicolons to separate parameters (not ? and & like other databases).
ADO.NET Format (classic)
The traditional format uses semicolon-separated key=value pairs:
Server=localhost,1433;Database=myapp;User Id=sa;Password=MyStr0ngP@ss;Encrypt=True;TrustServerCertificate=True
Note the port uses a comma separator (Server=host,port), not a colon.
Authentication Modes
SQL Server Authentication (username/password):
Server=localhost;Database=mydb;User Id=sa;Password=secret;
Windows Authentication (Integrated Security):
Server=localhost;Database=mydb;Integrated Security=True;
Azure AD Authentication:
Server=myserver.database.windows.net;Database=mydb;Authentication=Active Directory Default;
Encryption Parameters
| Parameter | Purpose |
|---|---|
Encrypt=True |
Enable TLS encryption |
TrustServerCertificate=True |
Skip certificate validation (dev only) |
HostNameInCertificate=*.database.windows.net |
Expected cert hostname |
Named Instances
SQL Server supports named instances using a backslash:
Server=localhost\SQLEXPRESS;Database=mydb;User Id=sa;Password=secret;
In a URI format, the backslash must be encoded:
sqlserver://sa:secret@localhost%5CSQLEXPRESS;database=mydb
Default Port
SQL Server defaults to port 1433. Named instances may use dynamic ports resolved via the SQL Server Browser service on UDP port 1434.
Use Case
Connecting an enterprise application, .NET service, or ORM like Prisma or TypeORM to a SQL Server instance — whether on-premises, in Azure SQL, or running in a Docker container.