Function: [AdventureWorks2016CTP3].[dbo].[ufnLeadingZeros]

CollapseAll image

Collapse image Function properties


 Name   Value 
 Schema   [dbo] 
 Owner   [dbo] 
 Creation date   23.10.2015 
 Type   Scalar 
 Is schema bound 
 Is deterministic 
 Encrypted   
 Implementation type   Transact SQL 
 ID   677577452 

Collapse image Creation options


Name Value
QUOTED_IDENTIFIER ON
ANSI_NULLS ON

Collapse image Parameters


Name  Description DataType  Max length  ReadOnly
@Value   int 4  

Collapse image Recordset returned


Name  Datatype  Max length 
@Return varchar 8

Collapse image Objects that depend on [dbo].[ufnLeadingZeros]


Object name Object type Dep level
[Sales].[Customer] Table 1
Total 1 object(s)

Collapse image Extended properties


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

Collapse image SQL


SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER 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
EXEC sp_addextendedproperty N'MS_Description', N'Scalar function used by the Sales.Customer table to help set the account number.', 'SCHEMA', N'dbo', 'FUNCTION', N'ufnLeadingZeros', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_Description', N'Input parameter for the scalar function ufnLeadingZeros. Enter a valid integer.', 'SCHEMA', N'dbo', 'FUNCTION', N'ufnLeadingZeros', 'PARAMETER', N'@Value'
GO

Collapse image See also


List of functions