Home Forums SQL Server 2005 Development Inserting Multiple Records Using Range Numbers RE: Inserting Multiple Records Using Range Numbers

  • Using a a Tally table to create this range of items is just simple. If you don't know what a Tally table is, please search this site. You will find a great article published by Jeff Moden.

    DECLARE

    @from INT,

    @to INT

    SELECT

    @from = 1,

    @to = 100

    SELECT

    'A' + REPLICATE('0', 9 - LEN(CONVERT(VARCHAR(10), N))) + CONVERT(VARCHAR(10), N)

    FROM Tally

    WHERE N BETWEEN @from AND @to