Visual InterDev

Populating a Database Project

See Also

A database project can contain one or more connections to databases. Each database contains database objects such as tables, queries, views, relationships, and indexes, in addition to the database's data.

You can create and modify the database objects and the data in three ways:

You use SQL scripts to give you complete control over the database, its objects, and its data. SQL scripts are files containing SQL statements that create and modify databases and database objects.

To populate a database project using SQL script files

  1. Add SQL script files to your database project.

  2. Execute the SQL script files against databases to which you've made a data connection. For information on how to do this, and what SQL script files contain, see Working with SQL Scripts.

Tips   Microsoft® Visual InterDev™ supplies a number of templates you can use to add SQL script files to your database project. When you right-click on a database project or one of its data connections and select the Add SQL Script command, the following templates are available: New SQL Script, New Stored Procedure Script, New Table Script, New Trigger Script, and New View Script.

The New SQL Script template adds a generic SQL script file to your database project, which you can use to create or modify any type of database object. The other templates create SQL scripts specific to SQL Server database objects.

You can also right-click a SQL Server database object in the Data View window and choose the Copy SQL Script command. You can then paste this SQL script into the SQL editor or directly into a database project. This creates an SQL script, which, when run against the database, will create the database object you selected.

You can also select multiple database objects in the Data View window and use the Copy SQL Script command to create an SQL script that you can add to a database project and use to create all the selected database objects. In addition to SQL Server database objects, the Copy SQL Script command also works with Oracle views, triggers, stored procedures, and functions, but not with Oracle tables and synonyms.

When you add a data connection to a database project, the data connection and database objects are displayed in Data View. You can edit the database objects directly. This is the easiest way to create and modify database objects and data, but you don't have as much control over the database as you do with SQL scripts.

To populate a database project using Data View

  1. Select the database object you want to modify, or choose a command to create a new object.

  2. Edit the data in the object directly, or use the SQL editor to modify the SQL statements in the object. For more information, see Managing Databases in Data View.

The Query Designer and Database Designer allow you to create and modify queries, tables, and objects associated with tables such as indexes, constraints, and relationships.

To populate a database project using the Database Designer

  1. In Data View, select the data connection containing the database.

  2. Select the database object (table or database diagram) you want to modify and choose the Design command from the shortcut menu.

    –or–

    Create a new table or new database diagram from the shortcut menu.

  3. Modify and save the database object.

To populate a database project using the Query Designer

  1. In the Project Explorer, select the data connection containing the database.

  2. Select the query you want to modify and choose the Design command from the shortcut menu.

    –or–

    Choose the New Query command from the shortcut menu.

  3. Modify and save the query.

For information on how to use the Query Designer and Database Designer, see Working with Database Projects.