把所有的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好累
试试下面的
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好累