SSIS错误:无法从SQL命令的参数中检索目标列说明

时间:2019-02-21 22:52:15

标签: sql sql-server ssis triggers etl

SSIS task

我遇到错误:

  

[将更新的记录加载到Table_vwAs_FixedIdentifier [85]]错误:无法从SQL命令的参数中检索目标列描述。

当我在图像中执行SSIS任务时。在oleDb更新任务的左下方“将更新的记录加载到Table_vwAs ..”中失败。它具有以下sql语句,并且还具有如下所示的触发器。到目前为止,我还无法确定此问题的原因。 当我禁用触发器时,任务运行成功。任何帮助都会令人大开眼界。

UPDATE
  [dbo].[Sec]
SET
       [SecID]=?
      ,[SECURITY_NAME]=?
      ,[SECURITY_SECTYPE_ID]=?
      ,[SECURITY_EXCHANGE_ID]=?      
WHERE
  [MasterID]=?

触发代码如下:

alter trigger [dbo].[TrTable_Fixed_AFTERUPDATE] on [dbo].[Sec]
after insert ,update
as
set NOCOUNT on

declare @DBMailDistributionListId varchar(50)
declare @ProfileName varchar(max)
declare @Recipients varchar(max)
declare @CopyRecipients varchar(max)
declare @BlindCopyRecipients varchar(max)
set @DBMailDistributionListId = 'Crossadyne1'
set @ProfileName = SharedCode.dbo.FnGetDBMailDistributionListProfileName(@DBMailDistributionListId)
set @Recipients = SharedCode.dbo.FnGetDBMailDistributionListRecipients(@DBMailDistributionListId)
set @CopyRecipients = SharedCode.dbo.FnGetDBMailDistributionListCopyRecipients(@DBMailDistributionListId)
set @BlindCopyRecipients = SharedCode.dbo.FnGetDBMailDistributionListBlindCopyRecipients(@DBMailDistributionListId)

declare @Subject varchar(max)
declare @Body varchar(max)
set @Body = ''

select distinct @Body = @Body + 'Master Sec ID: ' + convert(nvarchar(50) ,i.MasterId) + char(13) + char(10)
        + 'New Legal Entity ID: ' + convert(nvarchar(50) ,i.[INTERNAL_SECURITY_LEGALENTITY_ID])           
    from INSERTED i 
        inner join DELETED d
        on i.MasterId = d.MasterId
    where i.[INTERNAL_SECURITY_LEGALENTITY_ID] <> d.[INTERNAL_SECURITY_LEGALENTITY_ID]
        and i.Security_Change_Date = i.LegalEntityChangeDate
        and i.LegalEntityChangedBy not in (2 ,5)

if (@Body <> '') 
    begin

        set @Subject = 'WARNING: Crossadyne Security Legal Entity changed'

        exec msdb.dbo.sp_send_dbmail 
            @profile_name = @ProfileName
          , @recipients = @Recipients
          , @copy_recipients = @CopyRecipients
          , @blind_copy_recipients = @BlindCopyRecipients
          , @subject = @Subject
          , @body = @Body

    end


set @DBMailDistributionListId = 'test'
set @ProfileName = SharedCode.dbo.FnGetDBMailDistributionListProfileName(@DBMailDistributionListId)
set @Recipients = SharedCode.dbo.FnGetDBMailDistributionListRecipients(@DBMailDistributionListId)
set @CopyRecipients = SharedCode.dbo.FnGetDBMailDistributionListCopyRecipients(@DBMailDistributionListId)
set @BlindCopyRecipients = SharedCode.dbo.FnGetDBMailDistributionListBlindCopyRecipients(@DBMailDistributionListId)

set @Body = ''

select distinct @Body = @Body + 'Master ID: ' + convert(nvarchar(50) ,i.MasterId) + char(13) + char(10)            
        + 'Previous Legal Entity ID: ' + convert(nvarchar(50) ,d.[INTERNAL_SECURITY_LEGALENTITY_ID])           
    from INSERTED i 
        inner join DELETED d
        on i.MasterId = d.MasterId
    where i.[INTERNAL_SECURITY_ID] <> d.[INTERNAL_SECURITY_LEGALENTITY_ID]

if (@Body <> '') 
    begin

        set @Subject = 'WARNING: Crossadyne Security Legal Entity changed'

        exec msdb.dbo.sp_send_dbmail 
            @profile_name = @ProfileName
          , @recipients = @Recipients
          , @copy_recipients = @CopyRecipients
          , @blind_copy_recipients = @BlindCopyRecipients
          , @subject = @Subject
          , @body = @Body

    end

set NOCOUNT off

1 个答案:

答案 0 :(得分:1)

该问题是由于
exec msdb.dbo.sp_send_dbmail
在触发代码中,因为未在质量检查服务器上进行配置。我在评论这些内容后解决。