create table #temp (a int)declare @char varchar(1000),@i int,@num int
set @num=(select max(xh) from 原表)
set @i=1
while @i<=@num
begin
insert #temp values (@i)
set @i=@i+1
endselect a from #temp where a not in (select xh from 原表)
set @num=(select max(xh) from 原表)
set @i=1
while @i<=@num
begin
insert #temp values (@i)
set @i=@i+1
endselect a from #temp where a not in (select xh from 原表)
set @i = 1
while @i <= 10
begin
if not exists (select * from a1 where xh = @i)
print @i
set @i = @i + 1
end
declare @i int
set @i = 1
while @i <= 10
begin
if not exists (select * from a1 where xh = @i)
insert into #T values (@i)
set @i = @i + 1
end
select * from #T
insert into table1 values(1)
insert into table1 values(3)
insert into table1 values(4)
insert into table1 values(5)
insert into table1 values(7)
insert into table1 values(8)
insert into table1 values(10)
declare @ii int
create table #temptable (myNum int)
select @ii = 1
while (@ii<=10)
begin
insert into #temptable values(@ii)
select @ii = @ii + 1
end
select myNum from #temptable where not exists(select myNum from table1 where #temptable.myNum = table1.myNum)
drop table #temptable
drop table table1