SQL Server Reference

This section provides a comprehensive reference for Transact-SQL (T-SQL) commands, system functions, and objects used with Microsoft SQL Server.

Transact-SQL (T-SQL) Commands

Data Definition Language (DDL)

Commands used to define and modify database structures.

Data Manipulation Language (DML)

Commands used to manage data within database objects.

Data Control Language (DCL)

Commands used to manage permissions and access to data.

Transaction Control Language (TCL)

Commands used to manage transactions.

System Stored Procedures

Predefined stored procedures that perform administrative and diagnostic tasks.

Examples include:

For a complete list and detailed descriptions, please refer to the specific documentation for SQL Server system stored procedures.

Common T-SQL Syntax Examples

Creating a Table

CREATE TABLE Employees (
    EmployeeID INT PRIMARY KEY,
    FirstName VARCHAR(50) NOT NULL,
    LastName VARCHAR(50) NOT NULL,
    HireDate DATE,
    DepartmentID INT
);
            

Selecting Data with a Filter

SELECT EmployeeID, FirstName, LastName
FROM Employees
WHERE DepartmentID = 101;
            

Inserting Data

INSERT INTO Employees (EmployeeID, FirstName, LastName, HireDate, DepartmentID)
VALUES (1001, 'John', 'Doe', '2023-01-15', 101);
            

Updating Data

UPDATE Employees
SET DepartmentID = 102
WHERE EmployeeID = 1001;
            

Deleting Data

DELETE FROM Employees
WHERE EmployeeID = 1001;
            

System Functions

SQL Server provides a rich set of built-in functions for various purposes, including string manipulation, date/time operations, aggregate calculations, and more.

Aggregate Functions

Scalar Functions

Explore the Built-in Functions section for a comprehensive list and detailed explanations.

Database Objects

SQL Server supports various database objects that help in organizing, accessing, and managing data.

Key System Tables

SQL Server maintains system catalog views that provide metadata about the database.

Understanding these system objects is crucial for database administration and development.