Sql server 2008 如何使用SSI从两个或多个表执行联接和更新?
我正在SSIS上执行ETL任务。在这个任务中,我试图更新一个表'Vendor',其中我想使用另一个表作为'where'子句中的一些引用和条件。以下是我想做的-Sql server 2008 如何使用SSI从两个或多个表执行联接和更新?,sql-server-2008,ssis,Sql Server 2008,Ssis,我正在SSIS上执行ETL任务。在这个任务中,我试图更新一个表'Vendor',其中我想使用另一个表作为'where'子句中的一些引用和条件。以下是我想做的- ALTER TABLE Vendor ADD Imported BIT Update Vendor SET Imported = 1 -- (133 row(s) affected) Update Vendor SET Imported = 0 where VendorName in (Select Vendor
ALTER TABLE Vendor ADD Imported BIT
Update Vendor
SET Imported = 1
-- (133 row(s) affected)
Update Vendor
SET Imported = 0
where VendorName in (Select VendorName from MyDatabase..Vendor)
Update l
SET VendorName = t.VendorName, -- Vendor name looks imported one has proper Capital letters in name, use the one from to-be-imported one
Address1 = t.Address1,
Address2 = t.Address2,
City = t.City,
State = t.State,
Country = t.Country,
PostalZip = t.PostalCode,
Phone = t.NewPhone,
Email = t.Email
From MyDatabase..Vendor l, Vendor t
where l.VendorName = t.VendorName
and t.Imported = 0
-- (2 row(s) affected)
请建议我SSIS包上的适当程序。我可以使用executesql任务来完成相同的任务,但是我想使用另一种方法,就像在executesql任务中一样,我必须为每个SQL语句创建一个单独的任务。
您宝贵的答复将受到欢迎 要执行这样的多语句执行SQL任务,必须用分号结束每个单独的语句。这样做,它就会工作。我不认为每个SQL语句都需要单独的任务。您可以在同一个执行Sql任务上执行此操作。您可以解释一下我如何执行此操作吗?在您的控制流上添加一个执行Sql任务,并将Sql语句粘贴到Sql语句窗口上。另外,您真的需要每次都执行
alter table
吗?当我执行此操作时,我无法解析查询,查询失败。好的,我知道了,但是我们有其他方法吗?您可以将所有这些语句放在存储过程中,并从Execute SQL语句调用存储过程。