Basic SQL Syntax in MS SQL

Intermediate Updated March 20, 2025

✍️ Basic SQL Syntax in MS SQL

Here's a sample of basic T-SQL statements used in SQL Server:

-- Creating a table
CREATE TABLE Students (
    StudentID INT PRIMARY KEY,
    Name NVARCHAR(100),
    Age INT,
    EnrolledDate DATE
);

-- Inserting data
INSERT INTO Students (StudentID, Name, Age, EnrolledDate)
VALUES (1, 'Alice Johnson', 22, '2023-09-01');

-- Querying data
SELECT * FROM Students WHERE Age > 20;

🔍 T-SQL (Transact-SQL) is Microsoft’s proprietary extension of SQL that includes procedural programming, local variables, and error handling.