Updating existing records manually is one of those tasks that sounds simple—until you have hundreds or thousands of rows.
Maybe you need to:
Correct customer email addresses
Update product prices
Change order statuses
Refresh configuration values
Fix imported data
Writing hundreds of UPDATE statements by hand is slow and error-prone.
Instead, you can generate them directly from Excel or CSV using this free online Excel to SQL Generator:
👉 https://comtools.cn/Tools/Excel/ToSql
It can generate UPDATE, INSERT, DELETE, MERGE, and SELECT statements for multiple database engines.
When Should You Use UPDATE Instead of INSERT?
Use UPDATE when the records already exist in your database and you only need to modify specific columns.
Typical examples include:
Updating customer emails
Changing phone numbers
Fixing order statuses
Adjusting product prices
Refreshing configuration values
Correcting imported data
If the records don't already exist, use INSERT instead.
Prepare Your Excel File
The spreadsheet should be organized like this:
UserId Email Age
1001 new-alice@example.com 29
1002 new-bob@example.com 33
Requirements:
Row 1 contains column names
Data starts on Row 2
Keep primary keys in their own columns
Remove empty rows
Understanding SET and WHERE Columns
This is the most important concept when generating UPDATE statements.
Suppose your spreadsheet contains:
UserId Email Age
1001 new-alice@example.com 29
You would configure it like this:
SET Columns
These are the columns you want to change.
Email
Age
WHERE Columns
These identify which row should be updated.
UserId
Your generated SQL becomes:
UPDATE dbo.Users
SET
Email='new-alice@example.com',
Age=29
WHERE UserId=1001;
Never use the same column as both a SET column and a WHERE column.
Primary keys should almost always belong in the WHERE clause only.
Generate UPDATE SQL in Minutes
Using the online generator is straightforward:
Open https://comtools.cn/Tools/Excel/ToSql
Upload an Excel or CSV file
Select the worksheet
Choose UPDATE
Enter the table name (for example dbo.Users)
Select your database engine
Mark SET columns
Mark WHERE columns
Generate SQL
Copy or download the script
No manual SQL writing required.
Example Output
Input spreadsheet:
UserId Email Age
1001 new-alice@example.com 29
1002 new-bob@example.com 33
Generated SQL:
UPDATE dbo.Users
SET Email='new-alice@example.com',
Age=29
WHERE UserId=1001;
UPDATE dbo.Users
SET Email='new-bob@example.com',
Age=33
WHERE UserId=1002;
Different SQL dialects automatically use the appropriate identifier quoting for SQL Server, MySQL, PostgreSQL, Oracle, or SQLite.
Common UPDATE Scenarios
Task SET Columns WHERE Columns
Update email Email UserId
Update phone Phone CustomerId
Change order status Status, UpdatedAt OrderId
Update product price Price ProductId
Fix multiple fields Any editable fields Primary key
Composite key update Target fields Multiple key columns
Verify Before Updating
Before running hundreds of UPDATE statements, verify the target rows.
For example:
SELECT *
FROM dbo.Users
WHERE UserId IN (1001,1002);
This lets you confirm you're updating the intended records.
Many Excel-to-SQL tools can also generate SELECT statements for this purpose.
Safety Tips
A missing WHERE clause can update every row in a table.
Before running your script:
✅ Test in a staging database
✅ Verify affected rows
✅ Backup production data
✅ Execute updates in batches
✅ Review generated SQL before execution
Running 500–1000 UPDATE statements per batch is usually a good balance between speed and safety.
Working with Composite Keys
Some tables don't have a single primary key.
Instead, they use multiple columns.
Example:
CustomerId ProductId Quantity
Generated SQL:
UPDATE Sales
SET Quantity=5
WHERE CustomerId=100
AND ProductId=88;
The generator automatically combines multiple WHERE columns using AND.
Preview Data with Temporary Tables
A useful validation technique is importing spreadsheet data into a temporary table first.
If your table name starts with #, such as:
Preview
many SQL generators can create:
Temporary table
INSERT statements
Preview queries
DROP TABLE statement
This allows you to compare spreadsheet data with your production database before performing the real UPDATE.
UPDATE vs INSERT vs DELETE
Choosing the correct SQL statement matters.
Task Statement
Add new records INSERT
Modify existing records UPDATE
Remove records DELETE
Verify records SELECT
If you're unsure whether a row already exists, check first with a SELECT query.
Try the Free Excel to SQL Generator
If you frequently update database records from spreadsheets, the free Excel to SQL Generator can save a significant amount of time.
👉 https://comtools.cn/Tools/Excel/ToSql
Features include:
✅ UPDATE generation
✅ INSERT generation
✅ DELETE generation
✅ MERGE generation
✅ SELECT generation
✅ Excel (.xlsx) support
✅ CSV support
✅ SQL Server
✅ MySQL
✅ PostgreSQL
✅ Oracle
✅ SQLite
Simply upload your spreadsheet, configure the columns, and generate production-ready SQL in seconds.
Final Thoughts
Bulk updates don't have to involve hours of writing SQL manually.
By keeping your spreadsheet organized, correctly separating SET and WHERE columns, and validating your data before execution, you can safely update thousands of database records with minimal effort.
Whether you're maintaining customer data, correcting imports, or updating business records, generating SQL directly from Excel is faster, safer, and much easier than writing every UPDATE statement by hand.

Top comments (0)