How to: Generate Create Scripts

Create scripts are SQL script files that you can run to recreate the schema of a database object. This is useful for resetting a database object to its original condition. For example, you might use a create script to restore a table after extensive testing modifies the table. You can generate them only in connections made to SQL Server using the SQL Managed Provider.

Note

Create scripts recreate the structure of the database object but do not recreate the data.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To generate a create script

  1. Drag the script from Server Explorer onto the Create Script folder in Solution Explorer.

    -or-

    Open the database project where you want to save the Create script.

    Note

    You must have a database project created in a solution to generate a Create script. To create a new database project, from the File menu, click New Project and in the New Project dialog box, under Project Types open the Other Project Types node. Click Database, and in the Templates window click the Database template icon. Name the solution and then click OK.

  2. In Server Explorer, right-click the database object for which you want to generate create scripts.

  3. Choose Generate Create Script to Project from the shortcut menu.

See Also

Other Resources

Working with Scripts