Sunday, 12 October 2014

Bulk Insert Task - SSIS


Creating Format File

bcp <DB Name>..<TableName> format nul -c -t, -x -f myTestFormatFile.Xml -T


ex: bcp Test..Employee format nul -c -t, -x -f myTestFormatFile.Xml -T

// If Database supports windows Authentication
bcp dbname.schema.Products format -c -t -f d:\test.fmt -T
// For Sql Authentication use id and password with -U and -P in place of -T
bcp dbname.schema.Products format -c -t -f d:\test.fmt -Uusername -Ppassword

Code pages

CODEPAGE valueDescription
ACPColumns of charvarchar, or text data type are converted from the ANSI/Microsoft Windows® code page (ISO 1252) to the SQL Server code page.
OEM (default)Columns of charvarchar, or text data type are converted from the system OEM code page to the SQL Server code page.
RAWNo conversion from one code page to another occurs; this is the fastest option.
code_pageSpecific code page number, for example, 850.
DATAFILETYPE [ = {'char' | 'native' | 'widechar' | 'widenative' } ]
Specifies that BULK INSERT performs the copy operation using the specified default.
DATAFILETYPE valueDescription
char (default)Performs the bulk copy operation from a data file containing character data.
nativePerforms the bulk copy operation using the native (database) data types. The data file to load is created by bulk copying data from SQL Server using the bcp utility.
widecharPerforms the bulk copy operation from a data file containing Unicode characters.
widenativePerforms the same bulk copy operation as native, except charvarchar, and text columns are stored as Unicode in the data file. The data file to be loaded was created by bulk copying data from SQL Server using the bcp utility. This option offers a higher performance alternative to the widechar option, and is intended for transferring data from one computer running SQL Server to another by using a data file. Use this option when transferring data that contains ANSI extended characters in order to take advantage of native mode performance.

No comments:

Post a Comment