update top(100) A Set 姓名=b.姓名,身份证号=b.身份证号,记录号=b.记录号 from A,(select top(100) 姓名,身份证号,记录号 from B )as b
insert into B (姓名,身份证号,记录号) select top 100 姓名,身份证号,记录号 from A not exists (select * from b where a.姓名=b.姓名 and a.身份证号=book.身份证号 and a.记录号=b.记录号)
insert into B (姓名,身份证号,记录号) select top 100 姓名,身份证号,记录号 from A not exists (select * from b where a.姓名=b.姓名 and a.身份证号=b.身份证号 and a.记录号=b.记录号) order by newid()
insert into B (姓名,身份证号,记录号)
select top 100 姓名,身份证号,记录号 from A not exists
(select * from b where a.姓名=b.姓名 and a.身份证号=book.身份证号 and a.记录号=b.记录号)
select top 100 姓名,身份证号,记录号 from A not exists
(select * from b where a.姓名=b.姓名 and a.身份证号=b.身份证号 and a.记录号=b.记录号)
order by newid()
应该把A跟B换一下就对了吧我看楼主的意识是取A中的数据更新表B,对吧?虽然写的确实有点儿混乱
在关键字 'top' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,行 1
在关键字 'as' 附近有语法错误。
insert into B (姓名,身份证号,记录号)
select top 100 姓名,身份证号,记录号 from A where 身份证号 not in
(select 身份证号 from b )