IntercareSupport
asked on
Can't insert into temp table (insert_identity issue?)
I am having trouble inserting records into a temp table that I've created. When I execute the code below, it generates this error:
Cannot insert explicit value for identity column in table '#TEMP2___________________ __________ __________ __________ __________ __________ __________ __________ __________ __________ _000000003 091' when IDENTITY_INSERT is set to OFF.
When I try to set the identity to "on" (SET IDENTITY_INSERT [#TEMP2] ON), it errors out this way:
IDENTITY_INSERT is already ON for table 'Patient_List.dbo.Unique_U sers'. Cannot perform SET operation for table '#TEMP2'.
What am I doing wrong?
Cannot insert explicit value for identity column in table '#TEMP2___________________
When I try to set the identity to "on" (SET IDENTITY_INSERT [#TEMP2] ON), it errors out this way:
IDENTITY_INSERT is already ON for table 'Patient_List.dbo.Unique_U
What am I doing wrong?
INSERT INTO [#TEMP2]
(mpl_id, Last_Name, First_Name, DOB, Addr1, Add2, City, ST, Zip)
SELECT mpl_id, Last_Name, First_Name, DOB, Addr1, Add2, City, ST, Zip
FROM [#TEMP1]
WHERE (HP_Last_Visit =
(SELECT MAX(HP_Last_Visit) AS HP_Last_Visit
FROM [#TEMP1] AS l
WHERE (Last_Name = [#TEMP1].Last_Name) AND (First_Name = [#TEMP1].First_Name) AND (DOB = [#TEMP1].DOB)))
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!