Function:
[AdventureWorks2016CTP3].[dbo].[ufnLeadingZeros_native]
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 | 1732201221 |
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 |
SQL
SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION [dbo].ufnLeadingZeros_native( @Value int ) RETURNS varchar(8) WITH NATIVE_COMPILATION, SCHEMABINDING AS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'English') DECLARE @ReturnValue varchar(8); SET @ReturnValue = CONVERT(varchar(8), @Value); DECLARE @i int = 0, @count int = 8 - LEN(@ReturnValue) WHILE @i < @count BEGIN SET @ReturnValue = '0' + @ReturnValue; SET @i += 1 END RETURN (@ReturnValue); END GO |
See also