Transact‑SQL (T‑SQL) – Introduction
Transact‑SQL (T‑SQL) is Microsoft’s and Sybase’s proprietary extension to the SQL language used by Microsoft SQL Server and Azure SQL Database. It adds programming constructs, such as variables, loops, error handling, and functions, to the ANSI‑SQL standard.
Key Features
- Procedural programming constructs (IF, WHILE, TRY…CATCH)
- Rich set of built‑in functions for strings, dates, math, and more
- Support for user‑defined functions, stored procedures, and triggers
- Advanced query capabilities like CTEs, window functions, and MERGE
- Transaction control with BEGIN TRANSACTION, COMMIT, and ROLLBACK
Basic Syntax
A simple SELECT statement:
SELECT FirstName, LastName
FROM dbo.Employees
WHERE IsActive = 1
ORDER BY LastName;
Creating a stored procedure:
CREATE PROCEDURE dbo.GetEmployee
@EmpID int
AS
BEGIN
SET NOCOUNT ON;
SELECT *
FROM dbo.Employees
WHERE EmployeeID = @EmpID;
END;
Learning Path
Start with the basic SELECT, then explore data modification statements, and finally move on to advanced topics.