SQL Management Studio – How to generate change scripts

SQL Management Studio allows you to open a table in design mode, make changes then generate a “change script”.

The change script allows you to see exactly what changes will be made when you click ‘Save’, and where you have a test and production database you will also be able to use the change script to apply the exact same changes to the other database.

  1. Using SQL Management Studio, right-click on the table and select ‘Design’
  2. SQL-ChangeScript1
  3. Make the changes required, in this example we’re creating a new column called “New_Column”
  4. SQL-ChangeScript2
  5. Right-click in a blank area of the design window and select ‘Generate Change Script’
  6. SQL-ChangeScript3
  7. A new window will open with the change script displayed. You can choose to copy and paste the whole change script or click ‘Yes’ to save to a text file.
  8. SQL-ChangeScript4
  9. Remember – the changes have not yet been committed to your table, you will need to either save the changes to the table to run the change script to commit the changes.