Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SET IDENTITY_INSERT ON required

$
0
0

I want to insert records using the following code in ssis variable

if ((SELECT OBJECTPROPERTY( OBJECT_ID(N'[dbo].[TableName]'), 'TableHasIdentity')) = 1) begin SET IDENTITY_INSERT [dbo].[TableName] Off insert into [dbo].[TableName] select * from [efi_dot_com].[dbo].[TableName] SET IDENTITY_INSERT [dbo].[TableName] On end else insert into [dbo].[TableName] select * from [efi_dot_com].[dbo].[TableName]

Then I got error

An explicit value for the identity column in table 'dbo.TableName' can only be specified when a column list is used and IDENTITY_INSERT is ON.

The reason behind the erroir is try to use insert into with select * from ... with a table has identity (primary key) column.It is required to list out all the column name.

I can't list out all column names since the above code use dynamically for various tablename. How can I include the lsit of column name dynamically into the insert sql statement?

Is there other solution?

Thanks


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>