Labels

Wednesday, May 4, 2011

Append Zero to month number if month number is < 9

-- Append Zero to month number if month number is between 1 to 9:
select right('0'+(Convert(Varchar(3),[Month])),2) as MonthNumber from dbo.EmpSalaryDetailsbkp
-- OR
select right('0'+cast([MONTH] as varchar(3)),2) from EmpSalaryDetailsbkp

No comments:

Post a Comment