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
  • 732,580
  • 175
  • 1,330
  • 1,459
Nisar
  • 5,708
  • 17
  • 68
  • 83

2 Answers2

3

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

insert into tablename (column1, column2, ...)
select ... From ...
Frederik Gheysels
  • 56,135
  • 11
  • 101
  • 154
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
  • 11,389
  • 16
  • 53
  • 71