Transact-SQL (T-SQL) Statements

This section provides detailed documentation for Transact-SQL (T-SQL) statements, which are the fundamental building blocks for interacting with and managing Microsoft SQL Server. T-SQL is an extension of SQL that adds procedural programming, local variables, string and date processing functions, and other features.

Tip: Understanding T-SQL statements is crucial for efficient database development and administration. Explore the categories below to find the statements you need.

Statement Categories

Data Manipulation Language (DML) Statements

DML statements are used to retrieve, insert, update, and delete data in your database.

Data Definition Language (DDL) Statements

DDL statements are used to define, modify, and delete database objects such as tables, indexes, views, and stored procedures.

Data Control Language (DCL) Statements

DCL statements are used to manage permissions and access to database objects.

Transaction Control Language (TCL) Statements

TCL statements manage transactions within a database.

Control Flow Statements

Control flow statements enable you to manage the execution path of T-SQL code.

Example: Simple SELECT Statement

Here's a basic example of a SELECT statement to retrieve customer names and email addresses from a Customers table:


SELECT
    FirstName,
    LastName,
    Email
FROM
    Sales.Customers
WHERE
    CountryRegionCode = 'US';
            
Important: Always test DDL statements in a development environment before applying them to production databases. Incorrect DDL can lead to data loss or system unavailability.

For more detailed information on specific statements, including syntax, parameters, and examples, please refer to the individual documentation pages linked above.