How to Create a Table in SQL Server
Last updated July 25, 2026 · By the SaturnSQL team
Use CREATE TABLE with column definitions, and IDENTITY(1,1) for an auto-incrementing key. Add PRIMARY KEY, NOT NULL, and DEFAULT constraints inline.
CREATE TABLE orders (
id INT IDENTITY(1,1) PRIMARY KEY,
customer_id INT NOT NULL,
amount DECIMAL(12,2) NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'pending',
created_at DATETIME2 NOT NULL DEFAULT SYSDATETIME()
);Create only if it does not exist
IF OBJECT_ID('dbo.orders', 'U') IS NULL
CREATE TABLE dbo.orders (
id INT IDENTITY(1,1) PRIMARY KEY,
customer_id INT NOT NULL
);IDENTITY(seed, increment) starts at the seed and never reuses values, even after rollbacks, so gaps in the sequence are normal.
Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free