22,209
社区成员
发帖
与我相关
我的任务
分享
if object_id('temp') is not null drop table temp
select top 50 0 as id,100 as yhdzdID into temp
from syscolumns a,syscolumns b
declare @b int
select @b=-1
update Temp set yhdzdID=2,@b=yhdzdID,id=@b
select * from Temp
--更新前的值
0 100
0 100
0 100
0 100
0 100
0 100
0 100
--更新后的值
100 2
100 2
100 2
100 2
100 2
100 2
100 2
100 2
declare @b int
select @b=-1
update #Temp set yhdzdID=2
update #Temp set @b=yhdzdID
update #Temp set ID=@B
select * from #Temp
update #Temp set yhdzdID=2,id=yhdzdID
exec('update #Temp set yhdzdID=2,'+@b+'=yhdzdID,id='+@b )
create table test(b int)
insert into test select 1
insert into test select 1
insert into test select 1
insert into test select 1
insert into test select 1
insert into test select 1
declare @a int
set @a=0
update test set @a=@a+1,b=@a
select * from test
go
drop table test
------------------------------------
create table test(b int)
insert into test select 1
insert into test select 1
insert into test select 1
insert into test select 1
insert into test select 1
insert into test select 1
declare @a int
set @a=0
update test set b=@a,@a=@a+1 --區別
select * from test
go
drop table test