Transact-SQL Reference
Transact-SQL (T-SQL) is Microsoft's procedural extension of SQL, the standard language for relational database management. T-SQL adds procedural programming, local variables, command processing functions, and other programming constructs to SQL.
Getting Started
Learn the fundamentals of T-SQL, including basic syntax, data manipulation, and querying.
Key Components
Explore the core elements of Transact-SQL.
Data Types
Understand the various data types available in T-SQL for storing different kinds of information.
Common data types include:
INT
,BIGINT
,SMALLINT
,TINYINT
VARCHAR(n)
,NVARCHAR(n)
DECIMAL(p,s)
,NUMERIC(p,s)
DATE
,DATETIME
,DATETIME2
BIT
See the full Data Types section for details.
Statements
T-SQL provides a rich set of statements for managing and querying databases.
Key statements include:
SELECT
: Retrieve data from a database.INSERT
: Add new rows to a table.UPDATE
: Modify existing data in a table.DELETE
: Remove rows from a table.CREATE TABLE
: Define new tables.ALTER TABLE
: Modify existing table structures.DROP TABLE
: Remove tables from the database.CREATE PROCEDURE
: Define stored procedures.CREATE TRIGGER
: Define triggers.
Browse all Statements.
Functions
T-SQL offers built-in functions for performing calculations, manipulating strings, dates, and more.
Examples of common functions:
- String Functions:
LEN()
,SUBSTRING()
,UPPER()
,LOWER()
- Date Functions:
GETDATE()
,DATEADD()
,DATEDIFF()
- Aggregate Functions:
SUM()
,AVG()
,COUNT()
,MAX()
,MIN()
- System Functions:
DB_NAME()
,USER_NAME()
Explore the complete list of Functions.
Advanced Topics
Learn More
For deeper insights and best practices, check out these resources: