MS SQL databases in Plesk

Windows hosting offers Microsoft SQL Server databases in several versions. Each version is a separate server instance: MSSQLSERVER2012, MSSQLSERVER2014, MSSQLSERVER2016, MSSQLSERVER2017, MSSQLSERVER2019, MSSQLSERVER2022.

Creating a database

  1. Open Databases and click Add Database (more on creating a database).
  2. In the Database server list, choose the MS SQL instance. The default for MS SQL is 2012 — new projects usually use MSSQLSERVER2022.
  3. Set the database name, user name and password.
  4. Click Create Database.
Creating a database on the MSSQLSERVER2022 instance
Creating a database on the MSSQLSERVER2022 instance

The instance is chosen when you create the database. Remember which one you chose: you need it in the connection string.

Connection string

In the database card, click Connection info. The panel shows Host as .\MSSQLSERVER2022:0, plus the database name and user name.

Connection information: Host, Database name, User name
Connection information: Host, Database name, User name

In your site code, specify the server as localhost\<instance name> — the instance you chose:

Server=localhost\MSSQLSERVER2022;Database=client01_app;User Id=appuser;Password=YourPassword;TrustServerCertificate=True;

If you use plain Server=localhost, the connection goes to the 2012 instance, where your database does not exist, and you get Login failed for user (18456).

TrustServerCertificate=True is needed by newer versions of the Microsoft.Data.SqlClient driver, which encrypt the connection and validate the certificate by default.

Managing the database

There is no web admin tool for MS SQL in the panel. The database card offers Export dump, Import dump and Copy database (export and import). To work with tables and queries, use SQL Server Management Studio on your computer: in Server name, enter the server address from the hosting welcome email or from the panel, followed by a backslash and the instance, for example server_address\MSSQLSERVER2022. Authentication — SQL Server Authentication with the database user's login and password.

MS SQL database card
MS SQL database card
Questions and answers
Most often the connection string has no instance. Use localhost\MSSQLSERVER2022 (or your instance), not just localhost.
Create a new database on the target instance, move the data, and change the instance in the connection string.
phpMyAdmin works only with MariaDB/MySQL. For MS SQL use SQL Server Management Studio.