How to generate a range of numbers between two numbers?

后端 未结 30 1898
执念已碎
执念已碎 2020-11-22 10:16

I have two numbers as input from the user, like for example 1000 and 1050.

How do I generate the numbers between these two numbers, using

30条回答
  •  心在旅途
    2020-11-22 10:19

    I had to insert picture filepath into database using similar method. The query below worked fine:

    DECLARE @num INT = 8270058
    WHILE(@num<8270284)
    begin
        INSERT  INTO [dbo].[Galleries]
        (ImagePath) 
        VALUES 
        ('~/Content/Galeria/P'+CONVERT(varchar(10), @num)+'.JPG')
    
        SET @num = @num + 1
    end
    

    The code for you would be:

    DECLARE @num INT = 1000
    WHILE(@num<1051)
    begin
        SELECT @num
    
        SET @num = @num + 1
    end
    

提交回复
热议问题