How to BULK INSERT from text file to the table, which primary key is IDENTITY-constrained column?

Pocket

I’d like to describe how to BULK INSERT from text file to the table with IDENTITY-constrained primary key. You should insert a column into worksheet for primary key such as ‘AUTO_ID’.

TEXTfile

Transact-SQL code is following list. [Table] is table name, FullPath is complete file-path, and FileName is name of text file, respectively. WITH option phrase represents the first row is title.

BULK INSERT dbo.[Table] FROM 'FullPath\FileName.txt' WITH (FIRSTROW = 2);

Pocket

投稿者: admin

趣味:写真撮影とデータベース. カメラ:TOYO FIELD, Hasselblad 500C/M, Leica M6. SQL Server 2008 R2, MySQL, Microsoft Access.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です