Deborah's Developer MindScape






         Tips and Techniques for Web and .NET developers.

July 30, 2013

Creating a Table Script in a Database Project

Visual Studio 2012 introduced a new SQL Server Database Project. This post details how to create a new table script in your Database Project.

See this link for an introduction to the Visual Studio 2012 SQL Server Database Project.

To create a new table in a SQL Server Database Project:

1) In Solution Explorer, drill down into your SQL Server Database Project to dbo then to Tables.

image

2) Right-click on Tables and select Add | Table.

image

3) Enter the desired table name and click Add.

4) A script is added to the project for the new table:

image

5) The Table Designer is opened for entry of the table detail:

image

6) Use the Table Designer pane at the top OR the T-SQL pane on the bottom to define the columns for the table.

The two panes are kept in sync automatically.

image

7) Use the Properties window (View | Properties Window) to set additional properties for the fields on the table, such as the Identity information.

image

8) The defined properties are added to the script in the T-SQL pane:

image

9) When you have finished, click Save to save the script to the project.

Notice that there is no Update button on this designer. The table is not added to a database at this point. To update the database with the details from the new script, you need to publish the Database Project.

See this link for details on publishing a Database Project.

Use the Database Project to add table scripts instead of adding a table directly to your development database.

Enjoy!

RSS feed for comments on this post. TrackBack URI

Leave a comment

© 2019 Deborah's Developer MindScape   Provided by WPMU DEV -The WordPress Experts   Hosted by Microsoft MVPs