SELECT @TSTOCK=NULL,      @P_F0010=NULL,    @P_F0020=NULL,        @CASH=NULL                       
      这样写太麻烦了

解决方案 »

  1.   

    好象没有其它的办法吧。除非你写一个存储过程,然后就可以都调用这个,把你要修改的存储过程的变量全部改成NULL
      

  2.   

    上百个变量啊,真的是很麻烦,可是不清空的话,在游标中如果本次循环取到的是NULL值,就会用上次取到的值.
      

  3.   

    你说的是存储过程里面的变量呀。汗
    那只能一个一个用set了
      

  4.   

    -- NULL 就是 NULL, 不会用上条记录的值啊, 看下面的测试declare tb cursor local
    for
    select id = 2 union all
    select id = null
    declare @id int
    open tb
    fetch tb into @id
    while @@fetch_status = 0
    begin
    select @id
    fetch tb into @id
    end
    close tb
    deallocate tbdeclare tb cursor local
    for
    select id = 2 union all
    select id = null
    declare @id int
    open tb
    fetch tb into @id
    while @@fetch_status = 0
    begin
    select @id
    fetch tb into @id
    end
    close tb
    deallocate tb-- 结果: 2    NULL
      

  5.   

    No, you can give a new value to the parameter