Saving a Change Script
You can save an SQL
To save a change script
- Right-click inside the database diagram, and then click Save Change Script. This command is available whenever you have unsaved database changes in your diagram.
- In the Save Change Script dialog box, choose Yes.
Note If the option to automatically generate a change script is selected, a change script is generated whenever you save your database diagram or any changed database object in the diagram. This is helpful if you need to track the changes you have made to the database.
- A message box displays the file name of the saved change script. Choose OK.
Each time you save a change script, a new text file named DbDgmN.sql (where N equals 1 for the first change script you generate and N+1 for each subsequent change script) is created and saved in the current working directory.
The change script file lists any changed tables and how they were changed (using the DROP TABLE, ALTER TABLE, or CREATE TABLE SQL statements). The change script file also contains any error handling code that is required to clean up temporary tables or to rollback transactions that were part of unsuccessful changes (changes that could not be saved). In addition, the change script file contains code to make the script run successfully against the database and code (Print statements) that describe what the script is doing when it runs.
Any error messages that occurred while the changes were saved are stored in a log file, with the same name as the script file, except with a .log extension. You can also view messages showing which tables were successfully and unsuccessfully saved in the Log Viewer.
See Also
Database Changes Detected Dialog Box | Saving Selected Tables