select top 5 identity(int,1,1) as id into #tbl from sysobjects,syscolumns select id from #tbl where id not in (select id from a)
========================== 必须用到零时表吗
select * from (select '1' as id union all select '2' as id union all select '3' as id union all select '4' as id union all select '5' as id ) a where not exists(select 1 from tb where id=a.id)
select top 5 identity(int,1,1) as id into #t from sysobjects,syscolumns select t.id from #t t where not exists(select 1 from a where id=t.id)
--我只想出这个方法了 select top 5 identity(int,1,1) as id into #tbl from sysobjects,syscolumns select id from #tbl where id not in (select id from a)--如果ID多的话就加大临时表的行数 select top 10000 identity(int,1,1) as id into #tbl from sysobjects,syscolumns select id from #tbl where id not in (select id from a)
select id from #tbl where id not in (select id from a)
select top 5 identity(int,1,1) as id into #tbl from sysobjects,syscolumns
select id from #tbl where id not in (select id from a)
==========================
必须用到零时表吗
select '2' as id union all
select '3' as id union all
select '4' as id union all
select '5' as id ) a where not exists(select 1 from tb where id=a.id)
============
我的ID数量不是固定的,有可能很多呀
select t.id from #t t where not exists(select 1 from a where id=t.id)
select top 5 identity(int,1,1) as id into #tbl from sysobjects,syscolumns
select id from #tbl where id not in (select id from a)--如果ID多的话就加大临时表的行数
select top 10000 identity(int,1,1) as id into #tbl from sysobjects,syscolumns
select id from #tbl where id not in (select id from a)
很好用,谢谢