select sum(cast(fieldname as int)) from yourtable

解决方案 »

  1.   

    declare @s as varchar(8000)
    set @s=''
    select @s=@s+name from yourtable
      

  2.   

    declare cur_name cursor for Select 字段名 From 表
    declare str varchar(8000)
    set str = ''
    declare @str varchar(50)
    open cur_name
    fetch from cur_name into @str
    while(@@fetch_status = 0) 
    begin
    select str = str + @str
    fetch next from cur_name into @str
    end
    close cur_name
    deallocate cur_name
      

  3.   

    declare @s as varchar(8000)
    select @s=''
    select @s=@s+字段名 from tablename
    select @s
      

  4.   

    表A
    JNO        SNO        PNO        
    ---------- ---------- ---------- 
    11         22         33
    22         S2         P1
    33         S2         P3
    44         S3         P2
    56         S1         P2
    66         S2         P1
    77         S2         J1
    declare @s as varchar(8000)
    select @s=''
    select @s=@s+JNO+',' from a
    set @s=left(@s,len(@s)-1)
    select @s
    结果:
    11,22,33,44,56,66,77(1 row(s) affected)
      

  5.   


    declare @a varchar(8000)
    set @a=''
    select @a=@a+列 from 表setect @a 结果
      

  6.   

    declare @a varchar(8000)
    select @a=isNull(@a,'')+uid from t2
    select @a 结果
      

  7.   

    declare @a varchar(8000)
    select @a=isNull(@a,'')+uid from t2
    select @a 结果
    这种比较好