Properties

Owner: dbo 
Type: SQL scalar function 
Encrypted:  
Creation Date: 04/26/2006 
Modification Date: 04/26/2006 
Description: Scalar function used by the Sales.Customer table to help set the account number. 

Creation options

QUOTED_IDENTIFIER:  
ANSI_NULLS:  

Parameters

Name Direction DataType Length Default Description
  @RETURN_VALUE  RETURN  varchar     
  @Value  INPUT  int    Input parameter for the scalar function ufnLeadingZeros. Enter a valid integer. 
Total: 2 parameter(s)

Objects that depend on [dbo].[ufnLeadingZeros]

Object Name Owner Object Type Dep Level
  Customer  Sales  Table 
  CustomerAddress  Sales  Table 
  Individual  Sales  Table 
  SalesOrderHeader  Sales  Table 
  Store  Sales  Table 
  vIndividualCustomer  Sales  View 
  vIndividualDemographics  Sales  View 
  vSalesPersonSalesByFiscalYears  Sales  View 
  SalesOrderDetail  Sales  Table 
  SalesOrderHeaderSalesReason  Sales  Table 
  StoreContact  Sales  Table 
  iStore  Sales  Trigger 
  iuIndividual  Sales  Trigger 
  uSalesOrderHeader  Sales  Trigger 
  ufnGetContactInformation  dbo  Function 
  vStoreWithDemographics  Sales  View 
  iduSalesOrderDetail  Sales  Trigger 
Total: 17 object(s)

SQL

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

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;

GO
SET QUOTED_IDENTIFIER OFF
GO

GO
SET ANSI_NULLS OFF
GO

See Also

List of functions