LPAD Stored Procedure

I use the sp_LPAD stored procedure wherever I need to generate a padded string, like a bank account or serial number. It’s a bit like the Oracle built-in function of the same name, and can be called like this:

EXEC sp_LPAD @OrderRef OUTPUT 

Obviously, you’ll need to CAST or CONVERT the parameter if it is a numeric. By default the string will be padded with zeroes, although a second (optional) parameter can be specified which contains the pad character to use.

Author: James Page

Download Script:
lpad.sql



Disclaimer:
We hope that the information on these script pages is
valuable to you. Your use of the information contained in these pages,
however, is at your sole risk. All information on these pages is provided
“as -is”, without any warranty, whether express or implied, of its accuracy,
completeness, or fitness for a particular purpose…

Disclaimer Continued

Back to Database Journal Home

Get the Free Newsletter!

Subscribe to Cloud Insider for top news, trends & analysis

Latest Articles