insert b select * from a where a.id not in (select id from b)
create proc wsp @notfiter varchar(200)--不想写的字段,不能为空,也不能将所有字段都写上。 as declare @fiter varchar(500) select @fiter=isnull(@fiter+',','')+name from sysobjects where id=object_id('A') and charindex(name,@notfiter)!>0 exec('insert into B ('+ @fiter +') select '+@fiter+' from A where ~~~') --不想要id和name两个字段,这样写 exec wsp 'id,name'
create proc wsp
@notfiter varchar(200)--不想写的字段,不能为空,也不能将所有字段都写上。
as
declare @fiter varchar(500)
select @fiter=isnull(@fiter+',','')+name from sysobjects where id=object_id('A') and charindex(name,@notfiter)!>0
exec('insert into B ('+ @fiter +') select '+@fiter+' from A where ~~~')
--不想要id和name两个字段,这样写
exec wsp 'id,name'