表A:
注册编号,姓名
表B:
注册编号,姓名,年龄,学校insert into B(注册编号,姓名,年龄,学校) values (select top 1 注册编号 from A order by 注册编号 desc,@姓名,@年龄,@学校)---------------
select报错。
注册编号,姓名
表B:
注册编号,姓名,年龄,学校insert into B(注册编号,姓名,年龄,学校) values (select top 1 注册编号 from A order by 注册编号 desc,@姓名,@年龄,@学校)---------------
select报错。
set @注册编号=(select top 1 注册编号 from A order by 注册编号 desc)
insert into B(注册编号,姓名,年龄,学校)
select @注册编号,@姓名,@年龄,@学校
--或
insert into B(注册编号,姓名,年龄,学校)
select (select top 1 注册编号 from A order by 注册编号 desc),@姓名,@年龄,@学校
insert into B(注册编号,姓名,年龄,学校) select top 1 注册编号,@姓名,@年龄,@学校
from A
order by 注册编号 desc
select top 1 注册编号,@姓名,@年龄,@学校 from A order by 注册编号 desc
declare @t2 table (a char(3),b char(3),c char(3))
insert into @t1 (a,b) select 'a1','b1'
insert into @t1 (a,b) select 'a2','b2'
insert into @t1 (a,b) select 'a3','b3'
insert into @t2(a,b,c) select (select top 1 a from @t1 order by a),'bb','cc'
select * from @t2values 错误
请教语法上有何不同啊?