• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:



I have having a little trouble with this T-SQL procedure.

I need it to auto generate the ID field when I execute the command against my file.  But it keeps coming back with an error about Not for Replication.

Has anyone had experience of this when you have an Identity Column?

Thanks in advance

  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>I have having a little trouble with this T-SQL procedure.
which one?

when loading (external) files to sql tables, I can only recommend 1 thing:
use staging tables to bulk load the data to, validate there, and the copy to the final table.
see also here:

REA_ANDREWAuthor Commented:
I am using this

            BULK INSERT theusedcarsearch.dbo.tbl_Cars
               FROM 'D:\home\Default\theusedcarsearch.com\htdocs\Feeds\UsedCarSql.sql'
                    FIELDTERMINATOR ='¦',
                    ROWTERMINATOR = '\r\n',

completes 60,000 rows in 30 seconds, so for speed it is for me BUT, it complains about the ID column when I have the parameter KEEPIDENTITY

inline with

Guy Hengel [angelIII / a3]Billing EngineerCommented:
KEEPIDENTITY is when you want to insert the value for the identity field.
if your file does not contain such a column, you have 2 choices:
* the staging table as mentionned above
* create a view on the table that only returns the columns that the file contains, and use that view name in the BULK INSERT

  if the table is part of replication, you CANNOT use BULK insert directly on the table and you have only option 1) -> BULK INSERT into staging table , and normal INSERT into your final table.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now