SQL Server Bulk Insert

后端 未结 7 1524
说谎
说谎 2021-01-19 05:54

I want to import a one column text file into one of my sql tables. The file is just a list of swear words.

I\'ve written the following TSQL to do this



        
7条回答
  •  萌比男神i
    2021-01-19 06:26

    This is described in books on line for BULK INSERT under the KEEPIDENTITY argument. Here is what is says

    KEEPIDENTITY Specifies that the values for an identity column are present in the file imported. If KEEPIDENTITY is not given, the identity values for this column in the data file imported are ignored, and SQL Server automatically assigns unique values based on the seed and increment values specified during table creation. If the data file does not contain values for the identity column in the table or view, use a format file to specify that the identity column in the table or view should be skipped when importing data; SQL Server automatically assigns unique values for the column

    So, either use a format file or supply a dummy value and make sure not to use the KEEPIDENTITY argument

提交回复
热议问题