Solved

An explicit value for the identity column in table

Posted on 2014-10-25
4
240 Views
Last Modified: 2014-10-26
I am getting the following error:
Msg 8101, Level 16, State 1, Line 8
An explicit value for the identity column in table 'CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue' can only be specified when a column list is used and IDENTITY_INSERT is ON.
The code I have is listed below:
Thanks in advance for any help given.
SET identity_insert ProductVariantAttributeValue ON
SELECT * 
INTO CorpWear265_Restore_TestAlt..table1_originall 
FROM CorpWear265_Restore_Test.dbo.ProductVariantAttributeValue
DELETE CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue
USE CorpWear265_Restore_TestAlt
/*SET identity_insert ProductVariantAttributeValue OFF*/
INSERT INTO CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue 
SELECT * 
FROM CorpWear265_Restore_TestAlt..table1_originall
DROP TABLE CorpWear265_Restore_TestAlt..table1_originall
USE CorpWear265_Restore_TestAlt
SET identity_insert ProductVariantAttributeValue OFF
GO
SELECT TOP 14000 [Id]
      ,[ProductVariantAttributeId]
      ,[Name]
      ,[PriceAdjustment]
      ,[WeightAdjustment]
      ,[IsPreSelected]
      ,[DisplayOrder]
  FROM [CorpWear265_Restore_TestAlt].[dbo].[ProductVariantAttributeValue]
 
  /*
  where Name Like '%!%'
  */
  Go

Open in new window

0
Comment
Question by:homeshopper
  • 2
  • 2
4 Comments
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 40404198
Try rearranging so your Set Identity_insert ... line is after your USE line.
0
 

Author Comment

by:homeshopper
ID: 40404503
Thank you for your suggestion. The code I now have is below:
But it still gives the same error:
Msg 8101, Level 16, State 1, Line 7
An explicit value for the identity column in table 'CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue' can only be specified when a column list is used and IDENTITY_INSERT is ON.
SELECT * 
INTO CorpWear265_Restore_TestAlt..table1_originall 
FROM CorpWear265_Restore_Test.dbo.ProductVariantAttributeValue
DELETE CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue
USE CorpWear265_Restore_TestAlt
SET identity_insert ProductVariantAttributeValue ON
INSERT INTO CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue 
SELECT * 
FROM CorpWear265_Restore_TestAlt..table1_originall
DROP TABLE CorpWear265_Restore_TestAlt..table1_originall
USE CorpWear265_Restore_TestAlt
GO

Open in new window

0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 40404768
Oh, "... when a column list is used and..."

That's the piece we're missing.

INSERT INTO CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue
(Field1, Field2, ... Fieldn)
SELECT Field1, Field2, ... Fieldn
FROM CorpWear265_Restore_TestAlt..table1_originall
0
 

Author Comment

by:homeshopper
ID: 40404782
Thanks, it now works.
The final code I have is listed below for others to see:
SELECT * 
INTO CorpWear265_Restore_TestAlt..table1_originall 
FROM CorpWear265_Restore_Test.dbo.ProductVariantAttributeValue
DELETE CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue
USE CorpWear265_Restore_TestAlt
SET identity_insert ProductVariantAttributeValue ON
INSERT INTO CorpWear265_Restore_TestAlt.dbo.ProductVariantAttributeValue 
	   ([Id]
      ,[ProductVariantAttributeId]
      ,[Name]
      ,[PriceAdjustment]
      ,[WeightAdjustment]
      ,[IsPreSelected]
      ,[DisplayOrder])
SELECT [Id]
      ,[ProductVariantAttributeId]
      ,[Name]
      ,[PriceAdjustment]
      ,[WeightAdjustment]
      ,[IsPreSelected]
      ,[DisplayOrder]
FROM CorpWear265_Restore_TestAlt..table1_originall
DROP TABLE CorpWear265_Restore_TestAlt..table1_originall
USE CorpWear265_Restore_TestAlt
GO

Open in new window

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question