Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question
    
In SQL Server 2012, once you've changed a table in the designer, you can go to Table Designer > Generate Change Script. Not sure if that option is there on previous versions. –  Aaron Bertrand Oct 17 '12 at 0:44
    
Ah, excellent and its in 2008. Please write this up as an answer. –  Ian Warburton Oct 17 '12 at 0:50
2  
The long term answer is to become well-versed with T-SQL so you don't rely on GUI. –  Thomas Stringer Oct 17 '12 at 0:54
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
Yes.. hopefully seeing the scripts will help reduce my dependence on the designer. –  Ian Warburton Oct 17 '12 at 1:08
add comment

You can just go to the table after it is created in SSMS and right click and then select the Script options in the menu.

share|improve this answer
    
I don't think you can get ALTER statements like that, say, if I add a new column. –  Ian Warburton Oct 17 '12 at 0:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.