Many times, I have right clicked on a table in Sql Server 2005 Management Studio and been able to get the table definition. That's all well and good, but what if you want more information, such as triggers, indexes, or multiple tables? I've been using the lather-rinse-repeat method of right-clicking on each object, scripting the object, copying to my file, and moving onto the next object. There had to be a better way. Thanks to some help from Erland Sommarskog I have what I need. Ok, here's the steps:
- Right click on a database and select Tasks.
- Select the option to "Generate Scripts".
- A wizard pops up.
- Select the database.
- Make sure that you generate scripts for indexes, triggers, and anything else that is important to you.
- Select the object types that you want to script. Typically, I just script the tables, but practically anything can be scripted.
- Select the objects that you want to script.
- From there, you can finish it up.