--创建一个存储过程来计算就行了.
create proc p_calc
as
declare @s varchar(8000)
declare tb cursor for select s='update 表 set mon=('+bb+') where id='+cast(id as varchar) from 表
open tb
fetch next from tb into @s
while @@fetch_status=0
begin
  exec(@s)
  fetch next from tb into @s
end
close tb
deallocate tb

解决方案 »

  1.   

    create proc p_calc
    as
    declare @s varchar(8000)
    declare tb cursor for select s='update 表 set mon=('+bh+') where id='+cast(id as varchar) from 表
    open tb
    fetch next from tb into @s
    while @@fetch_status=0
    begin
      exec(@s)
      fetch next from tb into @s
    end
    close tb
    deallocate tb
      

  2.   

    如果你使用“:”和"@"号等,那么写一个通用的动态查询就行了。根据非公式记录生成变量声明和赋值语句,公式记录则生成update语句。
      

  3.   

    既然你们把变量定义成这种丑八怪模样,就只好在生成动态查询语句的时候对变量做一些变通(例如用A_A_A_代替:,用X_X_X_代替@)。
      

  4.   

    如果你使用“:”和"@"号等 
    ------------------------------>>>>
    如果你不使用“:”和"@"号等