SQL Server identity related error -
i using query in sql server 2008..
set identity_insert abc on bulk insert abc 'f:\test.csv' ( fieldterminator = ',', rowterminator = '\n' ) go
and getting error :
explicit value must specified identity column in table 'abc' either when identity_insert set on or when replication user inserting not replication identity column.
table structure 'abc' :
id [int] identity(1,1) not null, -- primary key aa [varchar](50) null, bb [varchar](50) null, cc [datetime] null, dd [varchar](50) null, ee [varchar](50) null, ff [int] null, gg [varchar](50) null, ii [int] null, jj [int] null
sample data csv file
84,0b0dbe1d,192.168.10.221,2012-07-27 16:15:41.503,0b0dbe1d_16-15-18,1.0.0,2,pra,2,null 85,111de4b6,192.168.10.221,2012-07-27 16:27:06.060,111de4b6_16-27-05,1.0.0,8,diane,5,null
the error says, need specify column names while inserting.
i don't think have option specify column names during bulk insert. can use below alternative.
select * dbo.stagingtable abc 1=2 go bulk insert stagingtable 'f:\test.csv' ( fieldterminator = ',', rowterminator = '\n' ) go set identity_insert abc on go insert abc (column1,column2,etc) select * stagingtable