When to use UPDATE instead of INSERT
Use UPDATE when rows already exist and you only need to change some columns:
- Bulk email or phone updates
- Fixing wrong order status or price after import
- Refreshing config by business key
- Rolling back a batch in a test database
ComTools Excel to SQL builds UPDATE scripts from Excel or CSV: pick SET columns (fields to change) and WHERE columns (row keys). Each spreadsheet row becomes one UPDATE statement.
Prepare your Excel file
Same rules as INSERT: row 1 is headers, data starts at row 2.
UPDATE example (keyed by UserId, updating Email and Age):
| UserId | Age | |
|---|---|---|
| 1001 | new-alice@example.com | 29 |
| 1002 | new-bob@example.com | 33 |
Important: A column used in SET must not also be marked as WHERE. Keep keys like UserId in WHERE only.
Steps (UPDATE)
- Open Excel to SQL.
- Upload
.xlsx,.xlsm, or.csv; select the target sheet. - Set statement type to Update.
- Enter the table name, e.g.
dbo.Users. - Choose database type (SQL Server, MySQL, PostgreSQL, etc.).
- In the column grid:
- Include columns → SQL
SETclause (Email, Age) - WHERE columns → match keys (UserId)
- Include columns → SQL
- Click Generate, then copy or download the SQL.
Sample output
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;
With quote identifiers enabled, column names follow the selected SQL dialect (e.g. [Email] on SQL Server).
Common scenarios
| Scenario | SET columns | WHERE columns |
|---|---|---|
| Change email by user ID | UserId | |
| Fix order status | Status, UpdatedAt | OrderId |
| Single field fix | Target field | Primary / business key |
| Composite key | Fields to update | Multiple WHERE columns (AND) |
Safety checklist
A wrong WHERE clause can touch too many rows:
- Run on a test database first; verify affected rows.
- Run an equivalent
SELECTbefore UPDATE (the tool also supports Select type for preview queries). - Back up tables or the database before production changes.
- Execute large scripts in batches of 500–1000 statements.
- At least one WHERE column is required—the tool blocks accidental full-table updates.
-- verify before UPDATE
SELECT * FROM dbo.Users WHERE UserId IN (1001, 1002);
Temp table preview
If the table name starts with # (e.g. #Preview), the tool will:
- Emit
CREATE TABLE - Insert preview rows so you can compare with Excel
- Append
SELECTandDROPat the end
Useful to validate spreadsheet data before applying UPDATE to a real table.
Work with INSERT and DELETE
| Task | Guide |
|---|---|
| New rows | INSERT guide |
| Edit existing rows | This UPDATE guide |
| Remove bad rows | DELETE guide (coming soon) |
| Multiple source files | Merge → Dedup → Excel to SQL |
Excel to SQL series
- Generate INSERT from Excel
- DELETE and CSV import guides (coming soon)
FAQ
Can one column be both SET and WHERE?
No. Keys belong in WHERE only.
Composite primary keys?
Mark multiple WHERE columns; the tool generates WHERE A = ... AND B = ....
Excel to SQL vs Generate UPDATE developer tool?
Generate UPDATE suits small pasted JSON rows; the Excel path is better for full sheets and many columns.
Batch multiple UPDATEs into one statement?
Each row is one UPDATE for easier review and rollback; run in chunks for large jobs.