How to connect to Azure SQL Database from Visual Studio Code

Before discussing the complete steps for this functionality, consider the prerequisites needed here.

Assuming you are ready with all these prerequisites. Follow the below steps

  1. Open Visual Studio Code from your local machine.
  2. Click on extensions from the left navigation –> search for mssql and click on the search result SQL Server (mssql) –> click on the Install button, as shown in the screenshot below.
connect to Azure SQL Database from Visual Studio Code

3. Now, you can see a SQL Server icon on the left navigation. Click on the SQL server icon –> click on the + Add connection button, as shown in the screenshot below.

Connect to Azure SQL from Visual Studio Code

4. Enter your Azure SQL server name and then hit the enter key from your keyboard.

how to connect to azure sql from visual studio code

5. Enter your Azure SQL database name and press enter. You can also press enter directly without entering the name.

how to connect to azure sql database from vs code

6. Choose the Authentication type based on the option you selected while creating the Azure SQL database. For me, it is SQL Login.

connect to azure sql from vs code

7. Enter the username that you entered during the Azure SQL database creation time.Press enter.

connect to azure sql database visual studio code

8. Now, enter the password you set during the creation time.Press enter.

connect to azure sql database from the visual studio code

9. Select Yes or No if you want to save the password or not based on your requirements. Press enter.

connect to the azure sql database from visual studio code

10. Enter a profile name and press enter.

how to connect to the azure sql database from visual studio code

11. You can see I connected to my Azure SQL Database successfully. Check out the screenshot below.

how to connect to azure sql db from visual studio code

Note: There might be a chance after step 10, you will get the below error.

Connection error azure sql database visual studio code

You can fix this error An instance-specific error occurred while establishing a connection to SQL server quickly and enjoy.

Video Tutorial

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!