How to: Create a Database Object
You must follow a two-step process to create a database object when your database is under version control. You must first add the object to your database project, and then you must build and deploy the changes to your database server. You can add a project item for the new database object from Solution Explorer or from Schema View.
For more information about how to build and deploy a new database, see How to: Prepare Database Build Scripts.
For more information about how to build and deploy changes to an existing database, see How to: Deploy Changes to New or Existing Databases.
To create a database object
Open the database project to which you want to add the item. For more information, see How to: Open a Database Project.
On the Project menu, click Add New Item.
The Add New Item dialog box appears.
In Categories, click the group that contains the type of database object that you want to create.
In Templates, click the template for the type of database object that you want to create.
In Name, type the name that you want to give the new database object.
Click Add.
The file that contains the database object is added to the database project in Solution Explorer. The database object is added in the Default Schema specified in the database project properties. When the object definition is valid, the new database object appears in Schema View. In addition, the object definition is opened in the Transact-SQL Editor, which you can use to modify the definition of the object. For information about how to validate your changes, see How to: Validate Database Objects.
Note
The default templates for some objects do not create valid objects until you edit the object definition. For example, when you add a new index, you must modify the object definition to specify the table to which the index applies before the index definition is valid.
After you modify the object definition, open the File menu, and click Save ObjectName.
If the definition is valid, the database object appears in Schema View. You can check your changes in to version control and then build and deploy your changes. For more information, see Building and Deploying Version-controlled Databases.
See Also
Tasks
How to: Modify Database Objects
Concepts
Working with Database Objects
An Overview of Database Creation and Deployment in a Team Environment
Terminology Overview of Team Edition for Database Professionals
Other Resources
How to: View Database Objects
Building and Deploying Version-controlled Databases
Getting Started with Database Projects
Working with Database Projects in a Team Environment