How To Query Azure SQL Database From Visual Studio

Introduction

In my previous article, you saw how to create an Azure SQL database and how to query the Database in the Azure portal. Azure SQL Database is a relational Database-as-a-Service which provides high performance, reliable, and secure database used to build data-driven applications and websites. In this blog, you will see how to query Azure SQL database from Visual Studio. As a prerequisite, make sure you have installed the latest version of Visual Studio on your machine and also, you have created a server-level firewall rule to access the database from your machine.

Query SQL Database

Log in to the Azure Portal.

Click SQL Databases -> vijaiDB (which I have created in my previous article). Click Tools.

 

Click "Open" in Visual Studio.

 

Visual Studio will be launched. Select Azure SQL database and enter all the required details and click Connect.

 

You will be successfully connected to the database from Visual Studio. Click on New Query, enter the query, and click Run. The results will be shown as shown below.

 

Result

Thus, in this article, you saw how to query Azure SQL database from Visual Studio.