Welcome Guest, you are in: Login

devio dbscript ScrewTurn Wiki

RSS RSS

Navigation





Search the wiki
»

PoweredBy

Page History: dbo ufnLeadingZeros (function)

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2010/01/09 18:07


wikibot

function dbo.ufnLeadingZeros
DescriptionScalar function used by the Sales.Customer table to help set the account number.

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;

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam.