Using the BULK INSERT Command
A Transact-SQL command for importing data into a database is BULK INSERT. You can use BULK INSERT in much the same way that you use BCP. In fact, most of the parameters for BULK INSERT are the same as those used with BCP—they just have a different syntax. This syntax is shown in Example 10-4.
Example 10-4. BULK INSERT Syntax and Usage
Syntax
BULK INSERT [database_name.[schema_name][table_name|view_name] FROM 'data_file' [ WITH ( [ [ , ] BATCHSIZE = batch_size ] [ [ , ] CHECK_CONSTRAINTS ] [ [ , ] CODEPAGE = { 'ACP' | 'OEM' | 'RAW' | 'code_page' } ] [ [ , ] DATAFILETYPE = { 'char' | 'native'| 'widechar' | 'widenative' } ] [ [ , ] FIELDTERMINATOR = 'field_terminator' ] [ [ , ] FIRSTROW =first_row ] [ [ , ] FIRE_TRIGGERS ...
Get Microsoft® SQL Server™ 2005 Administrator's Pocket Consultant now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.