💙 Supporting healthcare non-profits: Metadataloop is free for 6–12 months. Contact Us to get started.
Free Online Tool

CSV to SQL Server CREATE TABLE

Paste a CSV sample, get a T-SQL-dialect DDL with NVARCHAR, DATETIME2, and UNIQUEIDENTIFIER types.

Open the Schema Inferrer →

Overview

Generate a SQL Server CREATE TABLE from any CSV sample, with type mappings that match T-SQL conventions: BIT for booleans, UNIQUEIDENTIFIER for UUIDs, DATETIME2 for high-precision timestamps, and NVARCHAR(N) for Unicode-safe string columns.

What you get

✓ INCLUDED
T-SQL-native types: INT, BIGINT, DECIMAL, BIT, DATE, DATETIME2, UNIQUEIDENTIFIER, NVARCHAR(N), NVARCHAR(MAX)
✓ INCLUDED
Uses NVARCHAR for Unicode-safe storage by default
✓ INCLUDED
DATETIME2(7) precision when fractional seconds are present
✓ INCLUDED
Handles square-bracket-quoted reserved word column names
✓ INCLUDED
Output is ready for SSMS, Azure Data Studio, or sqlcmd

Type detection reference

Sample values and the dialect-native type they map to.

Sample valueInferred type
1, 1000INT
12345678901234BIGINT
12.50DECIMAL(10,2)
true, false, 0, 1BIT
2024-03-15DATE
2024-03-15 09:30:00.123DATETIME2(3)
a3bb189e-…UNIQUEIDENTIFIER
"Acme Corp"NVARCHAR(64)
paragraph > 4000 charsNVARCHAR(MAX)

Example

Input
ticket_id,subject,priority,opened_at,is_resolved
1,"Login broken",2,2024-03-15 09:30:00,0
2,"Cannot upload",1,2024-03-15 10:01:22,1
Output
CREATE TABLE tickets (
    ticket_id    INT           NOT NULL,
    subject      NVARCHAR(64)  NOT NULL,
    priority     INT           NOT NULL,
    opened_at    DATETIME2     NOT NULL,
    is_resolved  BIT           NOT NULL
);

Frequently asked questions

Why NVARCHAR instead of VARCHAR?
NVARCHAR stores Unicode (UTF-16). Defaulting to NVARCHAR avoids data loss for international characters at a small storage cost. Switch to VARCHAR if you've confirmed your data is ASCII-only.
What about DATETIME vs DATETIME2?
DATETIME2 is the modern type — wider date range, higher precision, recommended for new schemas. We emit DATETIME2 by default.
Does it generate SQL Server identity columns?
No. Add IDENTITY(1,1) manually to the column you want auto-incremented.

Try it now

No signup, no install — runs entirely in your browser.

Open the Schema Inferrer →

⚠ Confirm Delete