Advertisements
i have tried with sequence in snowflake but i need my first values need to start with 0000001 and end with increment as of
RecordID
0000001
0000002
0000003
0000004
0000005
0000006
0000007
0000008
0000009
0000010
0049443 –like this …but i am not able to achieve by sequence in snowflake?
drop TABLE foo
CREATE OR REPLACE TABLE foo (n NUMBER)
INSERT INTO foo VALUES (100), (101), (102)
SELECT n, s.nextval FROM foo, TABLE(GETNEXTVAL(seq1)) s
>Solution :
What about using GENERATOR and then using LPAD to account for the leading zeros?
SELECT
LPAD(rn, 6, '0') as padded_num
FROM
(
SELECT
seq4() as s,
row_number() over (
order by
seq4()
) as rn
FROM
TABLE(
GENERATOR(rowcount => 100)
)
) rs