連番のデータを持つテーブルを作る
/****** Object: Table [dbo].[NUM] Script Date: 2013/12/16 17:46:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[NUM](
[NUM] [int] NULL
) ON [PRIMARY]
GO
begin
DECLARE @num INT;
set @num = 1
while(@num <= 100)
begin
INSERT INTO NUM(NUM) VALUES(@num)
set @num = @num+1
end
end
データを比較する
select distinct num FROM NUM
where num <= (
SELECT MAX([Seq])
FROM [データ$]
) and
num not in
(
SELECT [Seq]
FROM [データ$]
)
order by num