SQL for inserting 1000's of numbers [resolved]
I want to insert values from
712000 to 713999 into a database
eg I want to loop through
x = 712000
while x < 714000
INSERT INTO tbRoute
(val1)
VALUES (x)
x = x + 1
loop
Can I do this in SQL (I am using SQL server), rather than having to code a trivial program.
Thanks
Re: SQL for inserting 1000's of numbers
That's how I'd do it with SQL using the following syntax. I'd use the SQL Query Analyzer to run it. A tip is to double up the characters used in loop statements (xx instead of x), makes trying to track them down in code easier. Here's the syntax for SQL.
Code:
Declare @xx as int
SET @xx = 712000
WHILE (@xx < 714000)
BEGIN
INSERT INTO tbRoute (val1) VALUES (@xx)
SET @xx = @xx + 1
END
Re: SQL for inserting 1000's of numbers