We will learn how to Connecting And Querying SQL Database From Azure Portal.
1. Select Query Editor(preview) from the Dmcdbpshell window.
2. We log in from the Query Editor screen.
3. On the Query Editor screen, we write 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, Quantity INT, sales MONEY ); |
— Let’s populate the orders table with Example datasets.
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; |
4. Press Run to run the query.
After the query runs, you will see the following output.
Connecting and Querying SQL Database from SQL Server Management Studio
We will connect and query an Azure SQL Database from SQL Server Management Studio.
1. We open SQL Server Management Studio, if the Server Type section is not selected on the “Connect to Server” screen, we select it as “Database Engine”.
2. You can see the Server Name information in the Azure portal in Azure SQL Database in the owerview window.
3. We choose SQL Server Authentication as the Authentication Type
4. Enter your login information for Azure SQL Server and press Connect.
If you receive an error stating that your client does not have access to the server with your IP address, you need to add the IP Address of the system you want to connect to Azure SQL Server Firewall in order to connect to Azure SQL Server.
I will explain this step in detail later. If you do not see a screen asking you to enter the IP address, the IP address of the system you want to connect to has been added to the -Azure SQL Server Firewall – Firewall.
5. 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, if you press F8, the Object Explorer screen will appear.