Hi,
I've got a field that stores numeric values, representing a tracking number.
I've also got a stored procedure that will extract this field and return it
to a client. However, I would like to return it slightly differently to the
way in which it is stored. Basically, I want to return it as TRK000nnn -
Where TRK is the string "TRK", 000 is zero-padding up to 4 zeros, and nnn is
the number itself - results would look something like this:
Tracking Number Formatted Value
1 TRK00001
24 TRK00024
43321 TRK43321
At the moment, a typical query could look something like this.
SELECT ("TRK" + CAST(trackNo AS varchar(10)))
FROM TB_Queue
But I'm not sure how to go about the zero padding. This would be easiest to
do on the client, but it is impractical (there are many client programs that
will use this stored procedure, and the format that it is returned as may
need to be altered in the future).
Many thanks,
Rowland.
I've got a field that stores numeric values, representing a tracking number.
I've also got a stored procedure that will extract this field and return it
to a client. However, I would like to return it slightly differently to the
way in which it is stored. Basically, I want to return it as TRK000nnn -
Where TRK is the string "TRK", 000 is zero-padding up to 4 zeros, and nnn is
the number itself - results would look something like this:
Tracking Number Formatted Value
1 TRK00001
24 TRK00024
43321 TRK43321
At the moment, a typical query could look something like this.
SELECT ("TRK" + CAST(trackNo AS varchar(10)))
FROM TB_Queue
But I'm not sure how to go about the zero padding. This would be easiest to
do on the client, but it is impractical (there are many client programs that
will use this stored procedure, and the format that it is returned as may
need to be altered in the future).
Many thanks,
Rowland.
Comment