现在我有一个表里面有idx ...idx 是从0....n的.我现在想把不所有的Idx值都减100
这个语句怎么写

解决方案 »

  1.   

    update 表 set idx =idx -100
      

  2.   

    这样的意思?update tablename set idx=idx100
      

  3.   

    SELECT idx=idx-100 from tbName
      

  4.   

    SELECT idx-100 idx from tab
      

  5.   

    --看錯了, 改改update tbName set idx=idx-100
      

  6.   

    把所有的idx字段都减100??
    试试下面的
    declare @col varchar(20)declare tc cursor
    static
    for select name from syscolumns where id=object_id('table1') and name like 'idx%'open tc
    fetch next from tc into @colwhile @@fetch_status = 0
    begin
       exec('update table1 set '+ @col +' = ' + @col + ' - 100');   fetch next from tc into @col
    endclose tc
    deallocate tc好累