We will learn how to connect azure database from sql management studio and from azure portal in this article.
- How to connect to azure sql database from azure portal
- How to connect azure database from sql management studio
How To Connect to Azure SQL Database from Azure Portal
Step1:
Select Query Editor(preview) from the dmcdbpshell window.
Step2:
Sign in at the Query Editor screen.
Step3:
In the Query Editor screen, type the following query.
Let’s create a new orders table
1 2 3 4 5 |
CREATE TABLE orders ( OrderID INT IDENTITY(1, 1) PRIMARY KEY, Amount INT, sales MONEY ); |
Let’s populate the orders table with sample data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
; WITH t1 AS (SELECT 1 AS a UNION ALL SELECT 1), t2 AS (SELECT 1 AS a FROM t1 CROSS JOIN t1 AS b), t3 AS (SELECT 1 AS a FROM t2 CROSS JOIN t2 AS b), t4 AS (SELECT 1 AS a FROM t3 CROSS JOIN t3 AS b), t5 AS (SELECT 1 AS a FROM t4 CROSS JOIN t4 AS b), nums AS (SELECT Row_number() OVER ( ORDER BY (SELECT NULL)) AS n FROM t5) INSERT INTO orders SELECT n, n * 10 FROM nums; GO SELECT TOP 10 * from orders; |
Step4:
Click Run to execute the query.
Step5:
After the query runs, you will see the following output.
How To Connect to Azure SQL Database from SQL Server Management Studio
We will be connecting and querying an Azure SQL Database from SQL Server Management Studio.
- Open SQL Server Management Studio, select “Database Engine” if the Server Type is not selected on the “Connect to Server” screen.
- You can see the Server Name information in the Azure portal in Azure SQL Database in the owerview window.
- Select SQL Server Authentication as Authentication Type
- Enter your login information for Azure SQL Server and press Connect.
If you get an error stating that your client’s IP address does not have access to the server, you need to add the IP Address of the system you want to connect to in Azure SQL Server Firewall. I will explain this step in detail later. If you do not see a screen asking you to enter your IP address, the IP address of the system you want to connect to has been added to Azure SQL Server Firewall.
If your operation is successful, you will be connected to Azure SQL Server as follows. If you do not see the following screen even though you are connected, press F8 and the Object Explorer screen will appear.