首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求解游标有关问题,在线急等

2012-02-14 
求解游标问题,在线急等!首先我已经写好了一个p_auto_store_bak的存储过程,该存储过程有6个参数,该6个参数

求解游标问题,在线急等!
首先我已经写好了一个p_auto_store_bak的存储过程,该存储过程有6个参数,该6个参数的取值来自于表u_batsale_c_bak,此表中有1000条记录,求解怎么通过游标实现自动从表u_batsale_c_bak中的每条记录里取6个对应值赋给存储过程的6个参数,从而执行存储过程??或者还有别的其它方法吗???

[解决办法]

SQL code
    declare cursor1 cursor for       select col1,col2,col3,col4,col5,col6    from u_batsale_c_bak --order by ...        open cursor1      fetch next from cursor_now into @col1,@col2,@col3,@col4,@col5,@col6    while @@fetch_status = 0    begin        exec p_auto_store_bak @col1,@col2,@col3,@col4,@col5,@col6        fetch next from cursor_now into @col1,@col2,@col3,@col4,@col5,@col6    end        close cursor1    deallocate cursor1
[解决办法]
还能想到的就是去拼接动态执行的SQL字符串。

热点排行
Bad Request.