Transact-SQL Reference for Azure SQL Database
This documentation provides a comprehensive reference for the Transact-SQL (T-SQL) language as implemented in Azure SQL Database. T-SQL is Microsoft's proprietary extension of SQL that is used to manage and query data in SQL Server and Azure SQL Database.
Key Components of T-SQL Reference
Data Types
Understand the various data types available in Azure SQL Database, including numeric, character, date and time, spatial, and XML types. Each data type has specific characteristics and storage requirements.
-- Example: Declaring a variable with a specific data type
DECLARE @orderCount INT;
DECLARE @productName VARCHAR(100);
DECLARE @orderDate DATETIME2(7);
DDL Statements (Data Definition Language)
Learn how to create, alter, and drop database objects such as tables, views, indexes, stored procedures, and functions using DDL statements like CREATE, ALTER, and DROP.
-- Example: Creating a simple table
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
HireDate DATE
);
Learn more about DDL Statements
DML Statements (Data Manipulation Language)
Master the commands used to insert, update, delete, and retrieve data from your database. This includes SELECT, INSERT, UPDATE, and DELETE statements, along with clauses like WHERE, GROUP BY, and ORDER BY.
-- Example: Inserting data into a table
INSERT INTO Employees (EmployeeID, FirstName, LastName, HireDate)
VALUES (101, 'Jane', 'Doe', '2023-01-15');
-- Example: Selecting data
SELECT FirstName, LastName
FROM Employees
WHERE HireDate >= '2023-01-01';
Functions
Utilize the built-in T-SQL functions for string manipulation, mathematical operations, date and time calculations, aggregate calculations, and more. This section also covers user-defined functions (UDFs).
-- Example: Using a string function
SELECT UPPER(FirstName) AS UpperFirstName
FROM Employees;
-- Example: Using an aggregate function
SELECT COUNT(*) AS TotalEmployees
FROM Employees;
System Stored Procedures and Views
Access system-level information and perform administrative tasks using system stored procedures and system catalog views. These provide insights into database performance, configuration, and metadata.
Explore System Stored Procedures