SQL Server (T-SQL)
Microsoft SQL Server's dialect — TOP, IDENTITY, bracket quoting, and friends.
- Limit rows with TOP and OFFSET/FETCH
- Use IDENTITY and bracket quoting
- Swap standard functions for their T-SQL forms
Microsoft SQL Server speaks T-SQL. The core querying you've learned all works; the differences are mostly in syntax for limiting rows, transaction handling, identity columns, quoting, and a handful of functions. (Not runnable here — the engine is SQLite.)
Limiting rows: TOP (and OFFSET/FETCH)
SQL Server has no LIMIT. Use TOP for "the first N":
SELECT TOP 5 name, price FROM products ORDER BY price DESC;For paging, use the SQL-standard OFFSET … FETCH (which SQL Server supports and
LIMIT-using engines also accept):
SELECT name FROM products ORDER BY name
OFFSET 10 ROWS FETCH NEXT 5 ROWS ONLY;Identity columns
Auto-increment is IDENTITY(seed, increment):
CREATE TABLE customers (
id INT IDENTITY(1,1) PRIMARY KEY,
name NVARCHAR(100) NOT NULL
);Note NVARCHAR for Unicode text — T-SQL distinguishes VARCHAR (ASCII) from
NVARCHAR.
Quoting and functions
- Identifiers are quoted with square brackets:
[Order Date](double quotes also work with a setting). Strings still use single quotes. ISNULL(x, y)replaces a NULL withy— the standard, portable form isCOALESCE(x, y), which T-SQL also supports.- Current time is
GETDATE()(vsCURRENT_TIMESTAMP). - String concatenation uses
+(orCONCAT(...)), not||.
Cheat-sheet
| Core / standard | SQL Server (T-SQL) |
|---|---|
LIMIT n | SELECT TOP n … |
| paging | OFFSET … FETCH NEXT … |
| auto id | IDENTITY(1,1) |
COALESCE(x,y) | ISNULL(x,y) (or COALESCE) |
| quote identifier | [My Column] |
| concat `a |
Where to go next
That completes the dialect appendices. The portable core you learned runs almost unchanged across all three — these tables are the small adjustments per engine.