当前位置: 首页 > 面试题库 >

SSIS错误:“源的外部列”与“数据源”列不同步;如何删除外部列?

缑修齐
2023-03-14
问题内容

查询应输出特定的项目列表,以及商店信息和经理信息之类的信息。使用游标浏览各种不同级别的管理列表,选择相关信息,然后向该人发送有关其所在地区/地区/商店的查询所返回内容的电子邮件。

我的问题与SSIS之旅息息相关。尽管代码的运行方式类似于运行,但是如果我单独运行Itemdata.dtsx(以查看错误),则会抛出错误:

“警告:组件“ Sources-ItemData”(1)的外部列与数据源列不同步。需要从外部列中删除外部列“ RM_Email”(49)。外部列“
SM_Email” (46)需要从外部列中删除。外部列“ DM_Email”(43)需要从外部列中删除。”

这导致SQL Server Mngt Studio说它已经运行,但是电子邮件的内容不过是表头而已。没有数据,无论我做什么,表头都不会改变。

我从源代码(在下面发布)及其使用的表中的任何提及中都删除了这些列。我想念什么?

BEGIN

SET NOCOUNT ON;

DECLARE @ProcedureName     varchar(255)
DECLARE @ExportFolder      varchar(255)
DECLARE @TempFolder        varchar(255)
DECLARE @WarningLevel      varchar(255) = 'log'
DECLARE @MsgDescription    varchar(2000) = ''
DECLARE @RecordCount       int = 0  
DECLARE @ReportDate        date = getdate()
DECLARE @Begdate           date = convert(date,(dateadd(month,-1,getdate())))
DECLARE @Enddate           date = convert(date,(dateadd(day,-1,getdate())))
DECLARE @Siteid            int 
DECLARE @Subject           varchar(75) = ''
DECLARE @Body              varchar(50) = ''
DECLARE @RMLastName        varchar(25)
DECLARE @RMFirstName           varchar(25)
DECLARE @RegionKey         int
DECLARE @DistrictKey       int
DECLARE @Email             varchar(50)

BEGIN TRY 
            --Table used as data source for each pass
            Truncate Table Example.dbo.itemdata


--Send reports to Regional Managers by building Cursor RMListCursor, 
--then running SELECT statement against each name (using @RMLastName and @RMFirstName to discern), 
--then emails results of SELECT statement to that Regional Manager. 
--Goes through CursorList, then ends. 
BEGIN
    --Set cursor for RM Email; returns all regional managers. 
DECLARE RMListCursor CURSOR FOR 
SELECT distinct t.lastname, t.firstname, t.Email
FROM Example.[dbo].[tblUser] t
JOIN example.dbo.vStoreDistrictRegionActive vs
    ON t.LastName = vs.RMLastName and t.FirstName = vs.RMFirstName 
ORDER BY LastName

OPEN RMListCursor

FETCH NEXT FROM RMListCursor
INTO @RMLastName
    , @RMFirstName
    , @Email

WHILE @@FETCH_STATUS = 0--(@SetInt < 6)

    BEGIN

    Truncate table Example.dbo.itemdata
    --Builds data, then inserts into Table built for this query. Note that there is no mention of DM_EMAIL, RM_EMAIL, or SM_EMail anywhere. 
    INSERT INTO Example.dbo.itemdata
        SELECT InvoiceNumber,
        shipFROMid,
        ad.SiteId,
        MfrCode,
        PartCode,
        UnitNetCore,
        ad.QuantityShipped,
        ShipDate,
        --First/Last Name of this item's store's District Manager. 
        rtrim(substring((SELECT ISNULL(DMfirstName,'') FROM example.dbo.vSiteRegionDistrictActiveV2 dm WHERE ad.siteid = dm.SiteNumber),1,30)) + ' ' +
            substring((SELECT ISNULL(DMLastName,'')  FROM example.dbo.vSiteRegionDistrictActiveV2 dm WHERE ad.siteid = dm.SiteNumber),1,30) DM
            --This is where DM_EMAIL, RM_EMAIL, and SM_EMail originally were before they were removed from both here and .ItemData.
        FROM example.dbo.vInvoiceHeaderDetail_Adis ad
            join example.dbo.Site ss on ad.SiteId=ss.siteid
            join example.dbo.vStoreDistrictRegionActive vs on ad.SiteId = vs.SiteId
        WHERE ad.siteid is not null and UnitNetCore>=250 and SUBSTRING(InvoiceNumber,2,1)='D' and QuantityShipped>0
            and isactive=1 and isowned=1 
            and ShipDate between @Begdate and @Enddate
            and vs.RMFirstName = @RMFirstName
            and vs.RMLastname = @RMLastName

            ORDER BY ad.SiteId,ShipFROMID,shipdate



    -- Execute SSIS package which downloads table to d: for email.

            set @RecordCount=@@ROWCOUNT

            --Quick check so that if the results were blank, don't bother sending a blank email. 
            IF @RecordCount<>0
                BEGIN

                    set @Subject = 'Cores billed from PWI >= $250 ' + cast(CONVERT(date,GETDATE()) as varchar(12))
                    set @Body    = 'Run date/time- ' + cast(GETDATE() as CHAR(20))

                    EXEC  xp_cmdshell 'd:\"Program Files (x86)"\"Microsoft SQL Server"\100\DTS\Binn\DTexec.exe  /f "D:\etl\bulk\ssis\Misc\ItemInfo.dtsx"'

                    EXEC msdb.dbo.sp_send_dbmail 
                        @profile_name   ='SQL Mail',
                        @recipients     ='test', --@email
                        @subject        = @Subject,
                        @body           = @Body,
                        @body_format    = 'HTML',
                        @File_attachments = 'D:\export\temp\ItemInfo.xls',                
                        @attach_query_result_as_file =0,
                        @query_attachment_filename='\ItemInfo.xls',
                        @query_result_width = 500

                END
        --Brings CURSOR back up to next name on List, repeats process. 
        FETCH NEXT FROM RMListCursor
            INTO @RMLastName
                , @RMFirstName
                , @Email
    END
END

CLOSE RMListCursor
DEALLOCATE RMListCursor

END TRY

BEGIN CATCH

    SET @WarningLevel = 'error'
    SET @MsgDescription = 'SQL Err= [' + CAST(ERROR_MESSAGE() as varchar(200)) + ' (' + CAST(ERROR_LINE() as varchar) + ')]' 
    EXEC example.dbo.spAddSysMessage  'Store Aging', @WarningLevel , @ProcedureName , '',  'EOM Store Aging Report', @RecordCount

END CATCH


 END

问题答案:

重新检查源和目标之间以及中间组件之间的列分配。

通过将数据流组件的属性ValidateExternalMetadata设置为False来尝试一下。

请也看看这个。



 类似资料:
  • 问题内容: 我有一个mysql数据库表,该表需要与ElasticSearch索引保持一致。我已经将表从表导出到es索引,但是现在我需要保持数据同步,否则搜索将很快变得过时。 我能想到的唯一方法是每隔X分钟导出一次表,然后将其与上次导入的表进行比较。这是不可行的,因为该表大约有1000万行,而且我不想整天每五分钟进行一次表导出。有什么好的解决方案?请注意,我仅具有对数据库的读取权限。 问题答案: 我

  • 一、简介 1.1 多数据源支持 Spark 支持以下六个核心数据源,同时 Spark 社区还提供了多达上百种数据源的读取方式,能够满足绝大部分使用场景。 CSV JSON Parquet ORC JDBC/ODBC connections Plain-text files 注:以下所有测试文件均可从本仓库的resources 目录进行下载 1.2 读数据格式 所有读取 API 遵循以下调用格式:

  • Generators 相关文章 The Basics Of ES6 Generators By Kyle Simpson ES6 generators in depth By Axel Rauschmayer redux-saga 相关文章 Redux nowadays : From actions creators to sagas By Riad Benguella Managing Side

  • 全局配置 在 nuxt.config.js 中配置你想引用的资源文件: module.exports = { head: { script: [ { src: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js' } ], link: [ { rel: 'style

  • 这里的TYPO3留档https://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/4-use-foreign-data-sources.html说,可以为extbase对象使用外部数据源:“这些外部数据源可能是来自同一个TYPO3数据库或网络服务的表。” 使用的数据映射器至少允许将对象映射到同一MySQL数据库中的任何表。 我对“或w

  • 我已经阅读了文档,但我不清楚以下情况: 消费者在scdf之外,处理器和接收器在里面。 所有提供的示例,三个组件都在里面。 从我的角度来看,我认为有两种解决方案: SCDF外部的生产者在SCDF中配置的主题中生成消息 在SCDF之外有另一个绑定器,处理器/接收器连接到SCDF之外的这个绑定器 如果有人能提供任何样本,它将非常有用