Page History: dbo ufnLeadingZeros (function)
Compare Page Revisions
Page Revision: 2010/02/11 09:04
wikibot
Function | dbo.ufnLeadingZeros |
Description | Scalar function used by the Sales.Customer table to help set the account number. |
Source
CREATE FUNCTION [dbo].[ufnLeadingZeros](
@Value int
)
RETURNS varchar(8)
WITH SCHEMABINDING
AS
BEGIN
DECLARE @ReturnValue varchar(8);
SET @ReturnValue = CONVERT(varchar(8), @Value);
SET @ReturnValue = REPLICATE('0', 8 - DATALENGTH(@ReturnValue)) + @ReturnValue;
RETURN (@ReturnValue);
END;