Connect to a SQL database with Visual Studio Code

Sarah Lean
3 min readOct 12, 2021

Does Visual Studio connect to SQL Server?

I’m a big fan of Visual Studio Code or VS Code as it’s sometimes referred to. It’s such a powerful tool, allowing you to write Markdown files, write your code, deploy services to Azure and YES it even let’s you connect to a SQL database and query it.

Extension

To use VS Code to connect to your SQL servers you need to have the extension installed. This is called SQL Server (mssql).

Visual Studio Code SQL Server extension

Once the extension is installed you will see a new icon down the left hand menu, it looks like a server icon. If you click on this you can start to create connections to your SQL servers.

Create connections

When you are in the extension blade you will see an “Add Connection” line, this is interactive and you can click on that to start to add connections for your SQL servers.

A dialog box will appear when you click on this asking for some details around your SQL server. This will either be the host name and instance or your Azure SQL server URL.

--

--

Sarah Lean

Community Speaker — Lifelong Learner — Founder of the Glasgow Azure User Group