This quickstart guides you through the process of creating an Azure SQL Database and learning to query data with Transact-SQL (T-SQL).
Before you begin, ensure you have the following:
Navigate to the Azure portal and select 'Create a resource'. Search for 'SQL Database' and click 'Create'. Fill in the required details, including a resource group, database name, server name, and administrative credentials. For this quickstart, you can use the default pricing tier.
Once the database is deployed, navigate to its resource page in the Azure portal. Under 'Settings', select 'Connection strings'. Copy the ADO.NET connection string (it will contain your server name, database name, and user ID). Open Azure Data Studio and create a new connection. Paste the connection string, enter your password, and click 'Connect'.
In Azure Data Studio, open a new query editor connected to your database. Execute the following T-SQL script to create a sample table named 'Products':
CREATE TABLE Products (
ProductID INT PRIMARY KEY IDENTITY(1,1),
ProductName VARCHAR(100) NOT NULL,
Category VARCHAR(50),
Price DECIMAL(10, 2)
);
Now, insert some sample data into the 'Products' table:
INSERT INTO Products (ProductName, Category, Price) VALUES
('Laptop', 'Electronics', 1200.00),
('Desk Chair', 'Furniture', 250.00),
('Coffee Mug', 'Kitchenware', 15.50);
Finally, query the data from the 'Products' table:
SELECT ProductID, ProductName, Price FROM Products WHERE Price > 100;
You should see the 'Laptop' and 'Desk Chair' records returned.
For more detailed information, refer to the full Azure SQL Database documentation.