集成SP查询执行显示未知错误

时间:2015-08-12 04:26:02

标签: sql sql-server sql-server-2012

执行SQL查询:

--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

此错误出现在执行查询:

  

消息8106,级别16,状态1,过程OAM_SP_MPS_Print_Traces_Insert,第105行
  表' sqlmas.GEN_U_Paper_Size'没有标识属性。无法执行SET操作。

代码:

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 个答案:

答案 0 :(得分:3)

您开启了没有<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 列的表格的IDENTITY_INSERT属性。从您的代码中删除这些行,您就可以了:

IDENTITY