Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Proceedure

Status
Not open for further replies.

DebbieChapman

Programmer
May 25, 2003
26
0
0
GB
I'm trying to write a stored proceedure that allows me to generate numbers into a table.

What I want to do is get a start number and end number then generate all the numbers in between in a specific format.

ie. start Number = 2 end number = 400

I then want to process these numbers into the following format

A0000002
A0000003
A0000004
etc etc until
A0000400

then write these numbers to a specfic table

I would appreciate any help on this
 
As usual, there's more than one way - Try this (untested)

declare i int
SET i = 2;
WHILE i <= 400 LOOP
INSERT INTO your_table( colname ) VALUES (right(&quot;A0000000&quot; + convert(varchar(3),i),8) )
SET i = i + 1
END LOOP


Dickie Bird (:)-)))
 
Oops - should be
(&quot;A&quot; + (&quot;0000000&quot; + convert(varchar(3),i),8)))



Dickie Bird (:)-)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top