Excel to SQL tutorial

Step-by-step guide from preparing your spreadsheet to running scripts in SQL Server using ComTools.

1. Prepare your Excel or CSV file

Row 1 must be column headers; data starts from row 2. Match column names to database fields. Use yyyy-MM-dd for dates; keep numeric columns free of text. CSV should be UTF-8, comma-delimited.

2. Upload and select worksheet

Upload .xlsx or .csv on the tool page. For multi-sheet workbooks, pick the target sheet. The tool reads row 1 as headers and shows all columns for mapping.

3. Generate INSERT scripts

Choose INSERT, enter table name (e.g. dbo.Users), check columns, click Generate SQL. One INSERT per row; strings and dates are quoted with escaped single quotes.

INSERT INTO dbo.Users (Name, Email, Age) VALUES ('Alice', 'alice@example.com', 28);
INSERT INTO dbo.Users (Name, Email, Age) VALUES ('Bob', 'bob@example.com', 32);

4. Generate UPDATE scripts

Choose UPDATE, check SET columns (fields to update) and WHERE columns (match keys) separately. A column cannot be both SET and WHERE. Use primary key or unique ID for WHERE.

UPDATE dbo.Users SET Email = 'new@example.com', Age = 29 WHERE UserId = 1001;
UPDATE dbo.Users SET Email = 'updated@example.com' WHERE UserId = 1002;

5. Generate DELETE scripts

Choose DELETE and check WHERE columns. One DELETE per row. Always test in a dev database first and back up production data.

DELETE FROM dbo.Orders WHERE OrderId = 'ORD-2024-001';
DELETE FROM dbo.Orders WHERE OrderId = 'ORD-2024-002';

6. Run in SQL Server

Copy or download the .sql file, open in SSMS, switch to target database (USE YourDatabase), then execute. Split large scripts to avoid transaction log growth.

Pro tips

  • Table names starting with # (e.g. #temp) auto-generate CREATE TABLE, SELECT, and DROP for easy preview and cleanup.
  • DB column names default to Excel headers with spaces removed; edit mappings to match actual field names.
  • For thousands of rows, download the .sql file instead of previewing in browser.
  • Files are deleted from the server immediately after processing.