I want to generate a range of auto-incremented characters between
two alphanumeric values. For example, AA to BA should generate
AA, AB, AC, AD,...BA. Your help in this regard is highly appreciated.
To continue reading for free, register below or login
Requires Membership to View
To read more you must become a member of SearchOracle.com
First of all, these aren't going to be "auto"-incremented.
If you're hoping to have the database generate these codes
automatically, it's not going to happen. The best you can do is
generate these codes yourself. Start by creating a LETTERS table:
create table letters
( letter char(1) not null primary key
);
insert into letters values
('A'),('B'),('C'),('D'),('E'),('F'),('G')
,('H'),('I'),('J'),('K'),('L'),('M'),('N')
,('O'),('P'),('Q'),('R'),('S'),('T'),('U')
,('V'),('W'),('X'),('Y'),('Z');
Now you can easily generate any range of codes like this:
select t1.letter||t2.letter
from letters as t1
cross
join letters as t2
where t1.letter||t2.letter
between 'AA' and 'BA'
Simple, eh?
Search and Browse the Expert Answer Center Search and browse more than 25,000 question and
answer pairs from more than 250 TechTarget industry experts.
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.