1

i am using following code but not working at all..

SET IDENTITY_INSERT MBR_INC_DTL_ ON
INSERT INTO MBR_INC_DTL_
SELECT * FROM MBR_INC_DTL__

error message showing..

Msg 8101, Level 16, State 1, Line 1
An explicit value for the identity column in table 'MBR_INC_DTL_' can only be specified when a column list is used and IDENTITY_INSERT is ON.

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
Nisar
  • 4,780
  • 15
  • 56
  • 78

2 Answers2

3

Simple, You don't use a column list in your insert statement:

insert into tablename (column1, column2, ...)
select ... From ...
Frederik Gheysels
  • 53,692
  • 9
  • 95
  • 146
3

Identity column must be specified first.

SET IDENTITY_INSERT MBR_INC_DTL_ ON

insert into MBR_INC_DTL_
(identity_column_name,
column2,
..
)
select 
identity_column_name,
column2,
..

SET IDENTITY_INSERT MBR_INC_DTL_ OFF
Prahalad Gaggar
  • 10,486
  • 16
  • 46
  • 66