How to: Generate a Script (SQL Server Management Studio)
You can create scripts using the Generate SQL Server Scripts Wizard, or using Object Explorer.
The Generate Scripts Wizard walks you through the process of creating scripts, and allows you to select a variety of objects to be scripted at once. The wizard has a variety of options for your scripts, including, such as whether to include permissions, collation, constraints, etc. Use the Wizard when creating scripts for a large number of objects. For information on the Generate SQL Server Scripts Wizard, see Generate SQL Server Scripts Wizard F1 Help.
Use Object Explore to quickly create scripts of an entire database, or a single database object using the default options. You can create the script in a Query Editor window, to a file, or to the clipboard.
You can create scripts to create or delete the objects. Some object types have additional scripting options, such as ALTER, SELECT, INSERT, UPDATE, DELETE, and EXECUTE.
Sometimes you want a script with multiple options, such as drop a procedure and then create a procedure, or create a table then alter a table. To create combined scripts, save the first script to a Query Editor window and the second to the clipboard so you can paste it into the window after the first script.
To script an object, expand Object Explorer and locate the object. Right-click the object and then click Script <object type> as.