读书人

SQL SSIS 的几个小问题

发布时间: 2012-02-11 09:51:35 作者: rapoo

SQL SSIS 的几个问题
大家好,
请问几个关于微软ssis工具的问题:
1 我下完断点,并且执行到该断点后如何查看变量的值呢?是否可以通过命令来查看?
2 如何通过sql命令的方式来验证sql语句的正确性?
3 现在有2个表A和B,主键是id:
表A:
1 小明 84分
2 小红 80分
3 小李 65分
表B
1 小明 80分
3 小李 82分

现在想以表A为依据,B更新到表A上,规则为:ID重复的就更新,A中没有的就添加。

多谢各位了。

[解决办法]
你这些工作只使用ssis来完成的话怕是做不了的,建议使用SQL语句或存储过程来做.

例如:
1.我下完断点,并且执行到该断点后如何查看变量的值呢?是否可以通过命令来查看?
在断点的地方
print (cast(变量 as varchar))

2.如何通过sql命令的方式来验证sql语句的正确性?
这个貌似没听说过有这样的东东,如果你找的话,也给我一个。

3。
--用B更新A?
update a set score = b.score from a , b where a.id = b.id
insert into a select * from b where not exists(select 1 from a where a.id = b.id)
或者这样更快
truncate table a
insert into a select * from b

--用A更新B?
update b set score = a.score from b , a where b.id = a.id
insert into b select * from a where not exists(select 1 from b where b.id = a.id)
或者这样更快
truncate table b
insert into b select * from a


[解决办法]
1.我下完断点,并且执行到该断点后如何查看变量的值呢?是否可以通过命令来查看?
在断点的地方
通过watch window 可以查看SSIS pachage里面的变量值的变化情况;
2 如何通过sql命令的方式来验证sql语句的正确性?
这个问题貌似有点矛盾
3 现在有2个表A和B,主键是id:
用SQL实现比较容易,效率较好的方法是使用left join

SQL code
-- updateupdate Aset A.Name = B.Name   ,A.score = B.scorefrom Ajoin B  on A.ID = B.ID;--insertinsert into A(name, score)select      B.name    ,B.scorefrom Bleft join A  on B.ID = A.IDwhere A.ID is null; 

读书人网 >SQL Server

热点推荐