Generating a Sequence of Numbers in SQL Server

Generating a Sequence of Numbers in SQL Server

You can use this method to fill the dropdown lists on a Web page, Combo box, or List box in a Windows application.

First, make the lists data-bound to a query or stored procedure.

CREATE PROCEDURE GetSequenceOfNumbers	@FirstNumber INT, @LastNumber INTASBEGIN--Validation -- you can also add code to see if the @FirstNumber is less than @LastNumber--Create the temporary tableCREATE TABLE #TEMP_SEQUENCE(DisplayLabel VARCHAR(10), Value INT)--Insert all the values between specified range..WHILE @LastNumber >= @FirstNumberBEGIN	INSERT INTO #TEMP_SEQUENCE VALUES (CAST(@FirstNumber AS VARCHAR), @FirstNumber)	SELECT @FirstNumber = @FirstNumber + 1END--return the values from temporary tableSELECT DisplayLabel, VALUE FROM #TEMP_SEQUENCEENDGO
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular