|
-
Dec 20th, 2006, 09:27 AM
#1
Thread Starter
Hyperactive Member
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
Last edited by Oliver1; Dec 21st, 2006 at 10:46 AM.
-
Dec 20th, 2006, 10:47 AM
#2
Lively Member
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
Last edited by Venus; Dec 20th, 2006 at 01:17 PM.
-
Dec 21st, 2006, 10:46 AM
#3
Thread Starter
Hyperactive Member
Re: SQL for inserting 1000's of numbers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|