Bulk Exporting Data from or Bulk Importing Data to a View

Usually you can bulk import data to a table view or bulk export data from a table view. These operations can include the export of data from multiple joined tables, the addition of a WHERE clause, or the performance of special formatting, such as a change of data formats by using the CONVERT function.

Bulk importing into a partitioned view is unsupported by BULK INSERT or INSERT ... SELECT * FROM OPENROWSET(BULK...) statements, and attempts to bulk import data into a partitioned view fail.

The rules for inserting data into a view apply to bulk-importing of data into a view.


When data is bulk-imported into a view, the treatment of default values depends on the command. For more information, see Keeping Nulls or Using Default Values During Bulk Import.


The following example uses a view of the HumanResources.DepartmentView table of the AdventureWorks sample database. From a query tool, such as Microsoft SQL Server Management Studio Query Editor, execute:

CREATE VIEW DepartmentView AS 
    SELECT DepartmentID, Name, GroupName 
    FROM HumanResources.Department;

The following command bulk exports the data from the DepartmentView view into the DepartmentView.txt data file. At the Microsoft Windows command prompt, enter:

bcp AdventureWorks..DepartmentView out DepartmentView.txt -c -T

To delete this sample view, execute the following Transact-SQL statement:

DROP VIEW DepartmentView;


For an example of using a view in a BULK INSERT command, see Using a Format File to Skip a Table Column.

See Also


Modifying Data Through a View
Scenarios for Bulk Importing and Exporting Data

Other Resources

bcp Utility

Help and Information

Getting SQL Server 2005 Assistance