Hello all,
I'm trying to create a custom auto-generated sequence number for a primary key.
The failing statement is this:
RETURN 'C' + right('0000' + CONVERT(varchar(10), @id))
I'm expecting the it to return sequential numbers as followed:
C0001
C0002
C0003
.
.
but I get the error: right function requires 2 argument(s).
I tried this:
RETURN 'C' + CONVERT(varchar(10), @id)
but I get:
C1
C2
C3
.
.
Also tried this:
RETURN 'C' + right('0000' + CONVERT(varchar(10), @id),4)
but I get: C0000, C0000,....
Can anyone please help with this?
Thanks in advance!
Aldi
I'm trying to create a custom auto-generated sequence number for a primary key.
The failing statement is this:
RETURN 'C' + right('0000' + CONVERT(varchar(10), @id))
I'm expecting the it to return sequential numbers as followed:
C0001
C0002
C0003
.
.
but I get the error: right function requires 2 argument(s).
I tried this:
RETURN 'C' + CONVERT(varchar(10), @id)
but I get:
C1
C2
C3
.
.
Also tried this:
RETURN 'C' + right('0000' + CONVERT(varchar(10), @id),4)
but I get: C0000, C0000,....
Can anyone please help with this?
Thanks in advance!
Aldi