0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

歯抜けデータのチェック

Posted at

連番のデータを持つテーブルを作る

/****** 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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?