declare @id int ,@condition varchar(50),@sql varchar(1000) declare clist cursor for select id,aa from js open clist fetch next from clist into @id,@condition while @@fetch_status=0 begin select @sql='update js set dd='+@condition+' where id='+str(@id) exec(@sql) fetch next from clist into @id,@condition end close clist deallocate clist