Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
Important
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.
Example
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;
GO
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;
GO
Note
For an example of using a view in a BULK INSERT command, see Using a Format File to Skip a Table Column.
See Also
Concepts
Modifying Data Through a View
Scenarios for Bulk Importing and Exporting Data
Other Resources
bcp Utility
BULK INSERT (Transact-SQL)
OPENROWSET (Transact-SQL)