create database in SQL Server
How to Prepare database in SQL Server and connect
-
Here, first we need to create a database in MS SQL server to connect to the docker container.
-
For that, Go to SQL server Management Studio Management Studio -> Give credetials and Connect to server
-
Right click on Databases -> New Database
-
In General page, Provide Database name and Owner. For example, here we given myDataBase and myUsername.
-
If you would like to create new user, check How to create new User in SQL Server.
-
You can provide the Owner name directly or check the name by click on the 3 dot button at the right side of the field.
- Enter the name in the field and click on Check Names. Click on Ok button.
-
Go to Options page in the window. There you can see the Collation field.
-
Select the collation SQL_Latin1_General_CP1_CS_AS from the dropdown and Click on OK.
-
You can see the the database is created in the SQL server.
-
We have to use connection string to connect the database from the docker container application.
-
Copy the following connection string and make changes on the myDatabase, myUsername and myPassword parts according to your SQL server
Data Source=host.docker.internal;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;TrustServerCertificate=True;
-
Login to System Admin and go to Database screen in the docker container application. Click on the Edit button in the window
- Change the Server Type into Cloud and paste the connection string on the following field.
- Click on the Save button. After that, click on Prepare Database button in below.
-
It takes some time and you will get a message "Completed". Click on Upgrade Database botton.
-
Click on the Test Connection button and you'll get a success message.
-
Now you're connected to the local SQL server database in docker container application and ready to use.