Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Pad Number

By dan_jf,

A simple UDF for padding out numbers with a specific character (eg: pad 3 to show as 003).

Usefull when you can only sort as a text item or for formatting purposes.

Script is similar to the SPACE() function but allow the padding character to be defined.

Usage:

dbo.padNumber('string to pad', padsize, padchar)

eg:

SELECT dbo.padNumber('53', 4, '0') as testNum

Returns:

testNum
-------
0053


Total article views: 189 | Views in the last 30 days: 1
 
Tags
 
Contribute