Data & JSON
CSV to SQL Server INSERT Generator
Convert CSV data into safe, properly escaped T-SQL INSERT statements for SQL Server.
This tool runs entirely in your browser. Nothing you paste or upload is sent to our servers.
CSV input
Paste CSV text or upload a .csv file. CSV is parsed locally in your browser and is never uploaded.
Characters: 0Rows: 0Columns: 0
No CSV loadedNo file selected
CSV parsing options
Read locally; never uploaded.
Table configuration
Schema and table names are validated and bracket-quoted. Spaces and special characters are supported.
Generated table identifier:[dbo].[MyTable]
SQL generation options
Column mapping & data types
All columns are selected by default. Renaming a SQL column never changes the original CSV data.
Uncheck to insert an empty string for text types. Non-text columns cannot represent an empty string.
Paste or upload CSV to configure columns.
Generate SQL
Generation status:Ready
Errors
CSV warnings
Generated SQL
Preview truncated. Copy SQL and Download .sql still contain the complete script.
Review the generated SQL before executing it. The tool does not connect to a database and cannot guarantee that the statements match your schema.
CSV contents and generated SQL stay in your browser. No file is uploaded and no SQL is executed.
How to use
- 1
Add CSV
Paste CSV text or upload a .csv file. Choose the delimiter, header row, trimming and empty-row behavior.
- 2
Map the table and columns
Enter the schema and table name, select columns, rename SQL columns, and review the inferred data types.
- 3
Review the types
Override types where needed, set DECIMAL precision/scale or string length, and fix any conversion errors.
- 4
Generate and copy
Generate T-SQL INSERT statements, review them, then copy or download the complete .sql file.
Example
CSV
EmployeeId,EmployeeName,Salary,IsActive
1001,John,5500.50,true
1002,"Mary, Jane",6200.00,falseGenerated T-SQL
INSERT INTO [dbo].[Employees]
([EmployeeId], [EmployeeName], [Salary], [IsActive])
VALUES
(1001, N'John', 5500.50, 1),
(1002, N'Mary, Jane', 6200.00, 0);
This example shows quoted commas, a text apostrophe, inferred decimal and bit values, and the resulting multi-row INSERT.
CSV to SQL Server INSERT generation guide
What is CSV to SQL conversion?
CSV to SQL conversion turns tabular text into INSERT statements that load the same rows into a SQL Server table. The CSV remains the source of the data; the generated script is a portable way to insert it.
This tool parses the CSV locally, infers or accepts a SQL type for each column, validates every value, and emits T-SQL. It does not connect to a database or execute the result.
How to convert CSV to SQL Server INSERT statements
Paste CSV text or upload a .csv file, confirm the delimiter and header settings, then enter the schema/table and review column mappings. Select the columns to include and generate the script.
The parser handles quoted commas, escaped double quotes, multiline fields, CRLF/LF, UTF-8 BOM, empties and Chinese characters. Inconsistent rows and unclosed quotes are reported rather than silently dropped.
Configuring table and schema names
SQL Server identifiers are wrapped in brackets. A closing bracket inside a name is escaped as ]] so the identifier remains data, not SQL. Spaces and special characters are supported.
Names are limited to 128 characters. The generator never concatenates an unvalidated schema, table or column name into executable SQL.
How SQL data type inference works
Inference examines every non-empty value in a column. It recognizes BIT tokens (true/false/1/0), canonical integers, DECIMAL values, scientific-notation FLOAT values, GUIDs, dates and unambiguous DATETIME2 values; everything else falls back to NVARCHAR.
Leading-zero values, mixed value kinds, timezone-bearing datetimes and oversized numbers deliberately fall back to NVARCHAR instead of being silently rounded or reinterpreted.
Overriding inferred types
Each column has an editable SQL name and type. Choosing DECIMAL exposes precision and scale; choosing NVARCHAR or VARCHAR exposes a length or MAX option. Changing a type revalidates every value before SQL is generated.
Invalid integers, out-of-range numbers, decimal precision/scale overflow, invalid dates or GUIDs, and strings that exceed the selected length are reported with the affected row and column.
How NULL values are handled
An empty CSV field becomes SQL NULL by default. A literal text value NULL is never converted automatically: for text columns it becomes N'NULL'. This distinction is preserved in the generated SQL.
Each column has an empty-field policy. Unchecking Empty field → SQL NULL inserts an empty string for text types. Numeric and date columns cannot represent an empty string, so that configuration is rejected rather than silently changed to NULL.
How Unicode strings are handled
NVARCHAR values are emitted with an N prefix, such as N'张三', and single quotes are doubled. Unicode characters, newlines and tabs are preserved inside the literal.
VARCHAR values are emitted without an N prefix. Choose NVARCHAR when the target column must store Chinese or other Unicode text regardless of the database collation.
Batch INSERT statements and transactions
Multiple rows can share one INSERT ... VALUES statement, or each row can have its own INSERT. The rows-per-INSERT setting splits large imports into smaller statements.
Optional BEGIN/COMMIT TRANSACTION, SET XACT_ABORT ON and GO separators make the script easier to integrate with SQL Server tooling. The tool does not execute any of these options itself.
Reviewing generated SQL safely
Treat the generated script as untrusted until reviewed. Confirm the schema, table, column order, data types and target database. Back up data and test in a non-production database first.
The tool validates syntax and values but cannot know your table constraints, triggers, permissions, collations or existing data. It makes no guarantee that every INSERT will succeed against every schema.
FAQ
Does this tool upload my CSV?
No. The CSV is read and parsed locally in your browser using the File API. Nothing is uploaded to a server, and generated SQL is never executed.
Does it execute the generated SQL?
No. This tool only creates a SQL script. You must review it and run it in your own SQL Server client with the appropriate database and permissions.
How are empty CSV fields handled?
By default, an empty field becomes SQL NULL. The literal text NULL is treated as the string N'NULL'. Each column has an Empty field → SQL NULL option; unchecking it emits an empty string for text types.
How are strings containing apostrophes handled?
Every single quote is doubled inside the SQL string literal. For example, O'Brien becomes N'O''Brien'. Semicolons, comments and other text remain inside the literal and are not executed.
Can I customize SQL data types?
Yes. Types are inferred from all non-empty values, and every column can be overridden. DECIMAL precision/scale and NVARCHAR/VARCHAR length or MAX are configurable, and invalid values block generation.
Does it support Unicode and Chinese characters?
Yes. NVARCHAR values use N-prefixed literals and preserve Unicode. When you manually choose VARCHAR, no N prefix is emitted; the database collation must be able to store the characters.
Can I generate multiple INSERT statements?
Yes. Choose multiple VALUES rows, one INSERT per row, and a rows-per-INSERT batch size. Optional transaction, SET XACT_ABORT ON and GO separators are available.
Does it support SQL Server?
Yes. The output is T-SQL for Microsoft SQL Server, with bracket-quoted identifiers and SQL Server-compatible DATE, DATETIME2 and UNIQUEIDENTIFIER literals.
Related tools
Available
Data & JSON
JSON Formatter
Beautify, minify, validate, and sort JSON with clear, line-aware error reporting.
Runs in your browserOpen tool
Available
Code generation
JSON to C# Class Generator
Generate clean C# classes from JSON, including nested objects, arrays, and nullable values.
Runs in your browserOpen tool