How the SQL UPDATE Generator works

The first line of the input names the columns, and every following line holds the values for one UPDATE statement. Values are split and interpreted the same way as in the SQL INSERT Generator: quoted values are always text, unquoted NULL is NULL, plain numbers stay numbers and true/false become the dialect's boolean.

The columns you list as key columns form the WHERE clause, joined with AND; a NULL key value is written as IS NULL. All remaining columns go into the SET clause. If you leave the key columns empty, the statements have no WHERE clause and would update every row in the table, so the tool shows a warning and puts a warning comment at the top of the output. The statements are only generated as text and are never run.

How to use the SQL UPDATE Generator

  1. Enter the table name and the key columns that identify each row, such as Id, separated by commas.
  2. In the input box, put the column names on the first line and one row of values per following line, or select Load example.
  3. Choose the dialect and the delimiter, and whether empty values become NULL.
  4. Select Generate UPDATE, or press Ctrl + Enter (Cmd + Enter on a Mac). Read any warning, then copy the SQL or download it as a .sql file.

Example

With table dbo.Products, key column Id, SQL Server and this input:

Id, Price, Description
501, 24.99, 'Wireless mouse, black'
502, 9.5, NULL

the generator writes:

UPDATE [dbo].[Products]
SET [Price] = 24.99, [Description] = 'Wireless mouse, black'
WHERE [Id] = 501;

UPDATE [dbo].[Products]
SET [Price] = 9.5, [Description] = NULL
WHERE [Id] = 502;

Common use cases

  • Applying a list of price or stock changes from a spreadsheet to a products table.
  • Correcting a batch of records identified by their IDs after a data import went wrong.
  • Preparing a reviewed change script for a production database instead of editing rows by hand.
  • Updating rows that are identified by a composite key, such as order number and line number.

Common errors and how to fix them

Every column is a key column, so nothing is left to SET
The key columns identify which rows to update, so at least one column must stay outside that set. Remove a column from the key list.
Enter a header row with column names, then one row of values per UPDATE
The input needs a header row followed by data rows. A single row on its own gives the generator nothing to work with.
The UPDATE would affect more rows than expected
The WHERE clause is built only from the key columns you choose. If those are not unique, one statement can update many rows. Test on a copy of the data first, and keep a backup.
Nothing is updated when the statements run
The key values in your data do not match any rows in the table. Check for trailing spaces, case differences or a type mismatch between your input and the stored values.

Frequently asked questions

How is the WHERE clause built?

Each key column becomes a condition such as [Id] = 42, joined with AND when there are several key columns. A key value of NULL is written as IS NULL, because = NULL never matches a row. All other columns go into the SET clause.

What happens if I do not enter key columns?

The statements are still generated, but without a WHERE clause, which would change every row in the table. The tool shows a warning in the status message and adds a WARNING comment at the top of the SQL so it is not run by mistake.

How are values quoted?

The same way as in the INSERT generator: unquoted numbers stay numbers, NULL becomes NULL, true and false become the dialect's boolean, and other values become escaped strings. Wrap a value in quotes to force text, for example '00123'. Tick Quote every value as text to write numbers and true/false as strings.

Can I update only some columns?

Yes. Include only the key columns and the columns you want to change in the header row. Columns that are not listed are not touched.

Does the generator run the UPDATE statements?

No. It only writes the SQL for you to review and run yourself. It never connects to a database, and your data is not sent to our server.