SQL Server 2005 – Populating the Database
In this tutorial you will learn how to populate the database in SQL Server 2005.
One method of populating the tables in a database is to right click on a table and select ‘Open Table’ and entering the data in the visual mode that is displayed.
Another method is to use the INSERT statement to add rows to a table. The syntax would be as under:
INSERT [INTO] table_or_view [(column_list)] data_values
The SELECT subquery in the INSERT statement can also be used to add values to a table or views. The use of the SELECT subquery also allows more than one row to be inserted at the same time. It must be ensured that the select list of the subquery matches the column list of the INSERT statement. If no column list is specified, the select list must match the columns in the table of view being inserted into.
Bulk copy operations can also be used to populate a database. A bulk copy program can be used. This is a command prompt utility that provides for running bulk copies in .bat and .cmd scripts. The BULK INSERT statement of T_SQL batches can be used. This statement has to be executed in the context of the server. Finally the bulk copy APIs for OLE DB, ODBC and DB-Library applications can be used. This is again a command prompt utility that uses the SQL Server ODBC driver bulk copy functions.