Excel to SQL examples
Sample outputs for common scenarios — use as reference when generating your own scripts.
Example 1: Bulk INSERT into users table
Excel headers: Name | Email | Age
Import new employees into dbo.Users — check all three columns, choose INSERT.
INSERT INTO dbo.Users (Name, Email, Age) VALUES ('Alice', 'alice@example.com', 26);
INSERT INTO dbo.Users (Name, Email, Age) VALUES ('Bob', 'bob@example.com', 31);
Example 2: Batch UPDATE by primary key
Excel headers: UserId | Email | Status
SET: Email, Status. WHERE: UserId. Batch-update email and status by user ID.
UPDATE dbo.Users SET Email = 'new1@example.com', Status = 'Active' WHERE UserId = 101;
UPDATE dbo.Users SET Email = 'new2@example.com', Status = 'Inactive' WHERE UserId = 102;
Example 3: Batch DELETE by order number
Excel header: OrderNo
WHERE: OrderNo. One DELETE per row matching order number.
DELETE FROM dbo.Orders WHERE OrderNo = 'SO-20240601';
DELETE FROM dbo.Orders WHERE OrderNo = 'SO-20240602';
Example 4: Full #temp script
Table name: #temp. Headers: ProductName | Price | Stock
Temp table names auto-generate CREATE TABLE, INSERTs, SELECT, and DROP.
CREATE TABLE #temp (ProductName NVARCHAR(255), Price DECIMAL(18,2), Stock INT);
INSERT INTO #temp (ProductName, Price, Stock) VALUES ('Keyboard', 199.00, 50);
INSERT INTO #temp (ProductName, Price, Stock) VALUES ('Mouse', 89.00, 120);
SELECT * FROM #temp;
DROP TABLE IF EXISTS #temp;
Example 5: CSV export to INSERT
CSV headers: City,Population,Region
Upload CSV directly — no need to convert to Excel first.
INSERT INTO dbo.Cities (City, Population, Region) VALUES ('Shanghai', 24870000, 'East');
INSERT INTO dbo.Cities (City, Population, Region) VALUES ('Beijing', 21890000, 'North');