C# 如何克服数据流任务中的 vs_needsnewmetadata 错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/124005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to overcome vs_needsnewmetadata error in Data Flow task?
提问by
I have an SSIS package that copies the data in a table from one SQL Server 2005 to another SQL Server 2005. I do this with a "Data Flow" task. In the package config file I expose the destination table name.
我有一个 SSIS 包,可将表中的数据从一个 SQL Server 2005 复制到另一个 SQL Server 2005。我使用“数据流”任务来完成此操作。在包配置文件中,我公开了目标表名称。
Problem is when I change the destination table name in the config file (via notepad) I get the following error "vs_needsnewmetadata". I think I understand the problem... the destination table column mapping is fixed when I first set up the package.
问题是当我更改配置文件中的目标表名称(通过记事本)时,我收到以下错误“vs_needsnewmetadata”。我想我明白这个问题了……当我第一次设置包时,目标表列映射是固定的。
Question: what's the easiest way to do the above with an ssis package?
问题:使用 ssis 包执行上述操作的最简单方法是什么?
I've read online about setting up the metadata programmatically and all but I'd like to avoid this. Also I wrote a C# console app that does everything just fine... all tables etc are specified in the app.config ... but apparently this solution isn't good enough.
我已经在线阅读了有关以编程方式设置元数据的内容,但我想避免这种情况。我还写了一个 C# 控制台应用程序,它做的一切都很好......所有表等都在 app.config 中指定......但显然这个解决方案还不够好。
回答by ctrlShiftBryan
If all you are doing is copying data from one SQL2005 server to another I would just create a Linked Server and use a stored proc to copy the data. An SSIS package is overkill.
如果您所做的只是将数据从一台 SQL2005 服务器复制到另一台服务器,我将创建一个链接服务器并使用存储过程来复制数据。SSIS 包是矫枉过正的。
Once the linked server is created you would just program something like...
创建链接服务器后,您只需编写类似...
INSERT INTO server1.dbo.database1.table1(id,name)
SELECT id, name FROM server2.dbo.database1.table1
As far the SSIS package I have always had to reopen and rebuild the package so that the meta data gets updated when modifying the tables column properties.
至于 SSIS 包,我总是不得不重新打开并重建包,以便在修改表列属性时更新元数据。
回答by Michael Entin
Check if the new destination table has the same columns as the old one.
检查新目标表是否与旧表具有相同的列。
I believe the error occurs if the columns are different, and the destination can no longer map its input columns to the table columns. If two tables have the same schema, this error should not occur.
我相信如果列不同,则会发生错误,并且目标无法再将其输入列映射到表列。如果两个表具有相同的架构,则不应发生此错误。
回答by Meff
Have you set DelayValidation to False on the Data Source Destination properties? If not, try that.
您是否在 Data Source Destination 属性上将 DelayValidation 设置为 False?如果没有,试试那个。
Edit: Of course that should be DelayValidation to True, so it just goes ahead and tries rather than checking. Also, instead of altering your package in Notepad, why not put the table name in a variable, put the variable into an Expression on the destination, then expose the variable in a .DtsConfig configuration file? Then you can change that without danger.
编辑:当然,这应该是 DelayValidation 为 True,所以它只是继续尝试而不是检查。此外,与其在记事本中更改包,不如将表名放在变量中,将变量放入目标上的表达式中,然后在 .DtsConfig 配置文件中公开变量?然后你可以毫无危险地改变它。
回答by Abhishek Jain
Matching source destination column with case sensitive has done the work for me.
匹配区分大小写的源目标列已经为我完成了工作。
Like in my case SrNo_prod
was column in dev and using it we developed the dtsx, while it is been created as SrNo_Prod
in prod, after making case change from P
to p
, we got successful execution of package.
就像我SrNo_prod
在 dev 中的 column一样,我们使用它开发了 dtsx,而它是SrNo_Prod
在 prod 中创建的,在将 case 更改为P
to 后p
,我们成功执行了包。