Click to Rate and Give Feedback

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
Other versions are also available for the following:
SQL Server 2008 Books Online (June 2009)
Scripting a Table

SQL Server Management Studio can create scripts to select, insert, update, and delete tables, and to create, alter, drop, or execute stored procedures.

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.

  1. In Object Explorer, expand your server, expand Databases, expand AdventureWorks, expand Tables, right-click HumanResources.Employee, and then point to Script Table As.

  2. The shortcut menu has six scripting options: CREATE To, DROP To, SELECT To, INSERT To, UPDATE To, and DELETE To. Point to UPDATE To, and then click New Query Editor Window.

  3. A new Query Editor window opens, makes a connection, and presents the entire update statement.

    This exercise demonstrates how the scripting feature can do more than just script the creation of a table or stored procedure. This new feature can help you quickly add data manipulation scripts to your project and easily script execution of stored procedures. This can be a big timesaver for tables and procedures with many fields.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker