# Function: ufnLeadingZeros

## Properties

Property | Value
--- | ---
Name | ufnLeadingZeros
ID | 69575286
Schema | dbo
Owner | dbo
Execute As | Caller
Type | SQL SCALAR FUNCTION
Uses Ansi Nulls |
Uses Quoted Identifier |
Is Schema Bound |
Uses Database Collation |
Null on Null Input |
Encrypted |
MS Shipped |
Published |
Schema Published |
Deterministic |
Precise |
System Verified |
System Data Access |
User Data Access |
Modify Date | 8/8/2010 5:21:43 PM
Creation Date | 8/8/2010 5:21:43 PM

## Extended Properties

Name | Value
--- | ---
MS_Description | Scalar function used by the Sales.Customer table to help set the account number.

## Permissions

No object level permissions defined.

## Parameters

Parameter Name | Datatype | Has Default Value | Default Value | Read Only | Xml Document | Description
--- | --- | --- | --- | --- | --- | ---
@Value | int |  |  |  |  | Input parameter for the scalar function ufnLeadingZeros. Enter a valid integer.

## Recordset Returned

Datatype | Has Default Value | Default Value | Xml Document | Description
--- | --- | --- | --- | ---
varchar(8) |  |  |  |

## Objects that depend on [ufnLeadingZeros]

- dbo.ufnLeadingZeros
  - Sales.Customer
    - dbo.ufnGetContactInformation
    - Sales.SalesOrderDetail
      - Sales.iduSalesOrderDetail
      - Sales.ufn_SalesByStore
    - Sales.SalesOrderHeader
      - Sales.SalesOrderHeaderSalesReason
      - Sales.uSalesOrderHeader
      - Sales.vSalesPersonSalesByFiscalYears
    - Sales.vIndividualCustomer

## Objects on which [ufnLeadingZeros] depends

- dbo.ufnLeadingZeros

## SQL

Script
SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON 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; EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Input parameter for the scalar function ufnLeadingZeros. Enter a valid integer.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'ufnLeadingZeros', @level2type=N'PARAMETER',@level2name=N'@Value' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Scalar function used by the Sales.Customer table to help set the account number.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'ufnLeadingZeros'

#### See also

List of Functions