问题
Executed SQL query:
--Scheduler SP
EXEC [SQLOAM].[OAM_SP_MPS_Print_Traces_Insert]
@intCompanyCode = 1,
@chrDomain = 'ECC-WEB',
@dtInsertedFrom ='01-Apr-2015',
@dtInsertedTo ='11-Aug-2015',
@intUID = 169558,
@intCommunityCode = 1
This error appears on exec that query:
Msg 8106, Level 16, State 1, Procedure OAM_SP_MPS_Print_Traces_Insert, Line 105
Table 'sqlmas.GEN_U_Paper_Size' does not have the identity property. Cannot perform SET operation.
Code:
UPDATE #Temp_OAM_MPS_Print_Traces
SET Temp_IsValid = 'N'
FROM #Temp_OAM_MPS_Print_Traces,
(SELECT
Temp_Print_Job_ID, Temp_Printer_ID, Temp_Printed_On, COUNT('x') cnt
FROM #Temp_OAM_MPS_Print_Traces
GROUP BY Temp_Print_Job_ID, Temp_Printer_ID, Temp_Printed_On
HAVING COUNT('x') > 1) a
WHERE
#Temp_OAM_MPS_Print_Traces.Temp_Print_Job_ID = a.Temp_Print_Job_ID
AND #Temp_OAM_MPS_Print_Traces.Temp_Printer_ID = a.Temp_Printer_ID
AND #Temp_OAM_MPS_Print_Traces.Temp_Printed_On = a.Temp_Printed_On
DELETE FROM #Temp_OAM_MPS_Print_Traces
WHERE Temp_IsValid = 'N'
BEGIN TRAN
SET IDENTITY_INSERT sqlmas.GEN_U_Paper_Size ON
if exists (select top 1 'X'
from HPPRINT.HPACJA.dbo.T_KnownMedia
where not exists (select top 1 'X'
from sqlmas.gen_u_paper_size
where UPS_PS_Code = id_KnownMedia))
begin
INSERT INTO sqlmas.GEN_U_Paper_Size (UPS_PS_Code, UPS_Description, UPS_Short_Description, UPS_Width, UPS_Height, UPS_Remarks, UPS_ISActive, UPS_Inserted_On, UPS_Inserted_By)
SELECT
id_knownmedia, lab_name, lab_name,
qty_width, qty_height, '', 'Y', GETDATE(), 251
FROM
HPPRINT.HPACJA.dbo.T_KnownMedia
WHERE
NOT EXISTS (SELECT TOP 1 'X'
FROM sqlmas.gen_u_paper_size
WHERE UPS_PS_Code = id_KnownMedia)
END
SET IDENTITY_INSERT sqlmas.GEN_U_Paper_Size OFF
回答1:
You're turning ON the IDENTITY_INSERT
property of a table with no IDENTITY
column. Remove these lines from your code and you're good to go:
set IDENTITY_INSERT sqlmas.GEN_U_Paper_Size ON
set IDENTITY_INSERT sqlmas.GEN_U_Paper_Size OFF
来源:https://stackoverflow.com/questions/31956015/integration-sp-query-execution-shows-unknown-error