2012-01-31 66 views
-1

我在那里我通过Execute SQL任务插入行表根据病情

我的XML包含像

<ROOT> 
<row firstName="Joe" lastName="Blow" city="Seattle" state="WA" phone="555-666-7777"/> 
<row firstName="Jane" lastName="Doe" city="Los Angeles" state="CA" phone="566-866-2345"/> 
<row firstName="Robert" lastName="Smith" city="Washington" state="DC" phone="444-555-6666"/> 
<row firstName="Mary" lastName="Contrary" city="Garden City" state="FL" phone="234-876-9374"/> 
<row firstName="Thomas" lastName="Doubter" city="New Orleans" state="LA" phone="384-389-7342"/> 
<row firstName="Barbara" lastName="Bologna" city="Chicago" state="IL" phone="483-483-8162"/> 
</ROOT> 

数据将XML数据转换成记录设置目的地和记录集目标数据库表中的包我已经在我的包装中取出四个变量的所有字符串类型的

firstname,lastname,city,state,phone  

现在,我的要求是,我需要这个XML数据插入到我基于名字的目的地表格。

如果我选择了firstname= Robert,则只有具有该名字的行必须输入到我的目标表中。

而我的执行SQL任务包含

Result set Property--single row 
connection type--OLEDB 
connection--myconnection 
sql statement--declare @firstName varchar(25) 
select @firstName= ? 
INSERT INTO people_xml (firstName, lastName,city,state,phone) 
    select firstName,lastName, city,state,phone from people_xml 
    where [email protected] 

Select Convert(varchar,Scope_Identity()) as SourceIDentity 

参数映射选项卡

user::firstname 
user::lastname 
user::city 
user::state 
user::phone 

结果集选项卡

result Name--0 
variable Name--User::SourceID 

当我运行它抛出一个错误,如

[Execute SQL Task] Error: Executing the query "declare @firstName varchar(25) select @firstName= ..." failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

+1

缩小的问题 – 2012-01-31 08:22:26

+3

StackOverflow的作品!在一个人们想互相帮助的前提下衡量一个人对某个主题的有用性和感知影响力与他们的声誉有关你已经询问了** [5个其他问题](http://stackoverflow.com/users/) 1025057/satishkumar?tab = questions)**但没有选择答案,也没有提供有用的答案。人们乐于花费精力帮助您找到答案,但您需要成为社区的优秀成员,并奖励他们的努力。投票或反馈,如果他们的解决方案不起作用 – billinkc 2012-01-31 13:26:10

回答

0

这个错误的问题是非常通用的。我个人得到这个错误两次。一旦我通过匹配字段LENGTHS来解决它。例如,我在表中使用了varchar(80),而在插入时使用了varchar(50)左右。我通过使用相同的类型和长度来解决它。

第二次我真的很麻烦,但幸运的是有一个人和我有同样的问题:我必须使用regsvr32注册sqltaskconnections.dll。在互联网上搜索它,你会在那里找到一个指南。

如果我是你,我会试试看。正如我之前所说的,这种错误实在是通用的,除非有人真的明智的答案,我的猜测是,你要奋斗很多= - (

希望这有助于