Using Visual Studio Code as a replacement for Sql Server Management Studio is very easy. Once you have downloaded and installed VSCode (download it here), you need to add the mssql extension in Visual Studio Code, which you can find here.

Then create a new file in VSCode and give it the extension .sql. The mssql extension enables mssql commands and T-SQL IntelliSense in the editor when the language mode is set to SQL. 

  1. Press CTRL+N. Visual Studio Code opens a new ‘Plain Text’ file by default.
  2. Press CTRL+K,M and change the language mode to SQL.SQL language mode
  3. Alternatively, open an existing file with .sql file extension. The language mode is automatically SQL for files that have the .sql extension.

Then you need to connect to your SQL Server:

  1. In VS Code, press CTRL+SHIFT+P (or F1) to open the Command Palette.
  2. Type sql to display the mssql commands.mssql commands
  3. Select the MS SQL: Connect command. You can simply type sqlcon and press ENTER.
  4. Follow the prompts to specify the connection properties for the new connection profile. After specifying each value, press ENTER to continue.
  5. Verify your connection in the status bar.

Connection status

Now you need to see your databases on your SQL Server. Simply use the following query:

Press CTRL+SHIFT+E to execute the Transact-SQL commands. View the results in the query window.

Then you can query any table in any database, for example:

Press CTRL+SHIFT+E to execute the Transact-SQL commands. View the results in the query window.

On the View menu, select Toggle Editor Group Layout to switch to vertical or horizontal split layout.

Voila, it’s as easy as this!

More information and examples are available here: Use Visual Studio Code to create and run Transact-SQL scripts for SQL Server.

3 Thoughts on “How Do I: Use Visual Studio Code instead of SSMS?

  1. Sheldon Butler on October 17, 2017 at 05:17 said:

    On the October Tenerife Preview, what is the actual name of the SQL Server we can connect to? I tried the new https://myvm.eastus.cloudapp.azure.com/NAV as we use in Visual Studio Code for AL, but it would not work. Thanks.

    • On the Tenerife Preview on Azure, these are the credentials you muse use:
      Username: SA
      Password: ‘same password as NAV admin user’
      The server name is: NAVSERVER\SQLEXPRESS

  2. Pingback: HOW DO I: USE VISUAL STUDIO CODE INSTEAD OF SSMS? | PA

Leave a Reply to srendersCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation