You can save a Transact-SQL change script if you don’t have security permissions to alter a database or if you’re not ready to update the database (for example, if you've made changes to the database diagram that conflict with changes made by other users). A Transact-SQL change script provides a record of your changes that can be applied to the database at a later time.
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 the next 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 Transact-SQL DROP TABLE, ALTER TABLE, or CREATE TABLE statements). The change script file also contains any error handling code that is required to clean up temporary tables or to roll back 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 describes 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. In the Microsoft® SQL Server™ error log, you can also view messages showing which tables were saved successfully and which unsuccessfully.
To save a change script
Viewing the SQL Server Error Log |