wsanchez
asked on
generating 8-digit sequence
how do i generate a full 8-digit sequence number using sql? for example, i would like to generate
00000001
00000002
00000003
instead of
1
2
3
i am using the postgresql database.
00000001
00000002
00000003
instead of
1
2
3
i am using the postgresql database.
ASKER
thanks for the suggestion, but is it possible to generate a sequence with all the digits from the very beginning? for example:
CREATE SEQUENCE seq_code;
CREATE TABLE table1 (
SequenceNum integer default nextval('SequenceNum'),
Field1 varchar(8)
);
for the 'SequenceNum' field under table1, i would like the sequence generated with all of the 8 digits.
thanks.
lgmm, nope, i'm not walter.
CREATE SEQUENCE seq_code;
CREATE TABLE table1 (
SequenceNum integer default nextval('SequenceNum'),
Field1 varchar(8)
);
for the 'SequenceNum' field under table1, i would like the sequence generated with all of the 8 digits.
thanks.
lgmm, nope, i'm not walter.
look for a mask, this kind of problems is common to solve with mask or something like this, some structure or picture command
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select cast(00000001 as string)
if you are using direct numbers like select 00000001 or something like this
try (select '00000001' as string) as number
are you walter sanchez?