Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Tagged as

Go to top

How to find a gap in the table between min and max value using pure SQL

, 12 Nov 2012
CREATE FUNCTION [dbo].[GetMissingNumbers](@ID int)RETURNS @MissingNr TABLE(MissingNumber int)ASbegin DECLARE @minValue int DECLARE @maxValue int Declare @checkValue int select @minValue = min(Sequence) from Table1 where ID = @ID select @maxValue = max(Sequence) from Table1...



Compare Revision Minor Date Status Editor
publicly available No 13-Nov-12 5:22 Available digimanus
added call to the function
1 No 13-Nov-12 5:22 Available digimanus


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) no name yet but one in mind
Netherlands Netherlands
I started in the eightees with Basic and QuickBasic. When the ninetees started dBase was my thing. Close to the millenium years I swapped to C++ and since 2003 it is only programming in c#.
There is one thing about me.
Not that kind of OO guy and definately not an ORM-fan. I know a database to well to give the importance of data out in the hands of a tool.
Follow on   Twitter

| Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 13 Nov 2012
Article Copyright 2012 by digimanus
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid