>>A table has an index column that starts at one and goes to N, with some missing values. Is there an SQL Select statement (its ok to use more than one) that will return the first x items that are NOT present in the column? >> >>TIA, >> >>Alex > >Create a Numbers table (see, for example): >http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/passing-multiple-ranges-to-stored-proced > >Once you have the Numbers table: >
>selecttop (N) N.Numberfrom myTable T RIGHTJOIN Numbers N on T.IndexCol = N.Number
>WHERE T.IndexCol ISNULL
>ORDERBY N.Number