Sql-server – How to get a copy of the SQL generated by Management Studio

sql serverssms

If I save a table in Management Studio's Table Designer for example, I believe it runs DDL SQL in the background. Is it possible for me to grab this SQL so that I can save it to a file?

Best Answer

Modern versions of SSMS (2008+ at least) allow you to generate a change script once you have made changes to a table using the graphical designer. You go to the menu item Table Designer > Generate Change Script.

enter image description here

That said, I agree with Thomas. In the long term, you should be proficient at T-SQL so that you can write ALTER TABLE scripts without the help of the wizard / graphical designers. They often do things you don't want to do.