User defined functions in MS SQL Server
Wednesday, September 5, 2007
AddZeroDigit
How to add Zero to an integer value from left (like 9 to 009)
Create function :
CREATE FUNCTION dbo.AddZeroDigit(@Value AS int)
RETURNS varchar(3)
BEGIN
DECLARE @Result varchar(3)
SET @Result = RIGHT('000'+CAST(@Value AS varchar(3)),3)
RETURN @ResultEND
Test :
SELECT dbo.AddZeroDigit(9) AS Result
Result :
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
About Me
set
View my complete profile
How to
How to create function
Query Technique
Crosstab Query
Insert Into Statement
Select Into Statement
Charcator Function
AddZeroDigit
Date Function
DayNameOfWeek
FindDate
NumberOfWeek
DateNextWeek
Numeric Function
IsZero
RoundDown
RoundUP
Blog Archive
►
2017
(1)
►
August
(1)
▼
2007
(12)
►
October
(3)
▼
September
(4)
IsZero
How to create function
AddZeroDigit
DayNameOfWeek
►
August
(5)
No comments:
Post a Comment