Microsoft’s and Sybase’s proprietary extension of the SQL standard, serving as the primary programming language for interacting with SQL Server to perform queries, data manipulation, and database administration.
-
Procedural programming: T-SQL extends ANSI SQL with procedural features such as variables, conditional statements (
IF/ELSE), loops (WHILE), error handling (TRY/CATCH), and stored procedures. -
Database administration: DBAs use T-SQL to create and modify database objects (DDL), manage security through
GRANT,REVOKE, andDENY, query Dynamic Management Views (DMVs), and develop maintenance scripts. -
Advanced features: >T-SQL includes capabilities such as Common Table Expressions (CTEs), window functions (
OVER/PARTITION BY), dynamic SQL usingsp_executesql,PIVOT/UNPIVOT, and JSON/XML data processing. - Application logic: Stored procedures, user-defined functions, and views are core building blocks of SQL Server applications. DBAs should understand how different T-SQL coding patterns affect query performance and scalability.
-
Best practice: Use parameterized queries, such as stored procedures or
sp_executesql, instead of dynamic string concatenation to improve execution plan reuse and protect against SQL injection attacks. - Related terms: Dynamic SQL, Query, SQL Server Management Studio, Execution Plan.
