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
  • 704,970
  • 168
  • 1,303
  • 1,425
Nisar
  • 5,280
  • 15
  • 61
  • 82

2 Answers2

3

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

insert into tablename (column1, column2, ...)
select ... From ...
Frederik Gheysels
  • 55,176
  • 9
  • 97
  • 148
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,932
  • 16
  • 49
  • 68