How It Works: Bulk Insert (BCP.exe) – Injecting a Sort Operation


 

Move from: bobsql.com

The customer reported that they could not BCP into a table using “keepidentity” and after more debugging I found that “keepidentity” was not the issue but the issue was the addition of a clustered index.

 

The table is defined with 100s of sparse columns:

CREATE TABLE [dbo].[Mytable](

       [DataId] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,

       [MainId] [int] NOT NULL,

       [YearId] [char](2) NOT NULL,

       [UserId] [int] NOT NULL,

       [DateAdded] [datetime] NOT NULL,

       [DateLstMod] [datetime] NOT NULL,

       [C1] [varchar](max) SPARSE NULL,

       [C2] [varchar](max) SPARSE NULL,

       [C3] [varchar](max)