日期:2014-05-17 浏览次数:20594 次
declare @id int=0;
select @id =Id from 表A where name='美国'
update 表C
set BBB=@id
where sss=(select MAX(sss) from 表C)
if object_id('Tempdb..#a') is not null drop table #a
if object_id('Tempdb..#b') is not null drop table #b
if object_id('Tempdb..#c') is not null drop table #c
create table #a(
ID int not null,
[name] nvarchar(100) null
)
create table #b(
ID int not null,
[AID] int null
)
create table #c(
ID int not null,
[BID] int null,
[SSS] int null,
[BBB] int null
)
Insert into #a
select 1,'中国' union all
select 2,'美国'