How to preview the exact SQL each database will receive
Use Ctrl+Shift+V to see a script after variable substitution, for one target, before anything is sent.
Published
A script with variables is not the script that runs. Each database gets its own version, and a typo in a variable value is cheapest to find before you press run.
Preview with Ctrl+Shift+V
With your script open and a target group selected, press Ctrl+Shift+V. A dialog shows the SQL one target will receive, after substitution, and names that target at the top.
For example, this script:
USE {{target.database|ident}};
UPDATE dbo.Settings SET Region = {{region}} WHERE Id = {{settingId}};
previews as the real statement for that database, with the database name quoted as an identifier, the region as a string literal and the id validated as a number.
What to look for
- The database name matches the target named at the top.
- Quoting is right.
textandidentifiervariables are escaped for you, and anumberthat is not a number fails before anything runs. - Raw substitutions are flagged. If a variable is
raw, its value becomes part of the SQL verbatim, and the preview warns you. Use|literalor|identunless the value really is SQL.
Make it a habit before anything you cannot undo. It is the only way to see what a raw variable actually put into your statement.
Read more about the four variable types.