Partager via


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

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Development Settings in Visual Studio.

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