Function:
[AdventureWorks2016CTP3].[dbo].[ufnLeadingZeros]
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 |
Creation options
| Name | Value |
| QUOTED_IDENTIFIER | ON |
| ANSI_NULLS | ON |
Parameters
| Name | Description | DataType | Max length | ReadOnly |
| @Value | int | 4 |
Recordset returned
| Name | Datatype | Max length |
| @Return | varchar | 8 |
Objects that depend on [dbo].[ufnLeadingZeros]
| Object name | Object type | Dep level |
| [Sales].[Customer] | Table | 1 |
Extended properties
| Name | Value |
| MS_Description | Scalar function used by the Sales.Customer table to help set the account number. |
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 |
See also