Hi,
I have a simple query that getting some datas like below;
ID , Month
1 5
2 12
3 3
For example I want to change "Month" column's value. For example if there is 1, and I'll show with January. And if there is 12, I'll show December.
How can I do that with MSSQL?
Regards.
Changing values with another value
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Jan 7, 2015, 1:18 PM EST
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 7, 2015, 6:09 PM EST
if you want to pass only month number then you can do something like
DECLARE @Mth smallint
SET @Mth = 1
SELECT DateName(mm,DATEADD(mm,@Mth,-1)) as [MonthName]
if you want to apply it for your table then use it likeCreate Table #Monthtbl
(
Id int,
MonthNo int
)
insert into #Monthtbl values(1,1)
insert into #Monthtbl values(2,2)
insert into #Monthtbl values(3,3)
insert into #Monthtbl values(4,4)
SELECT Id,DateName(mm,DATEADD(mm,MonthNo,-1)) as [MonthName] from #Monthtbl
Pradeep ShetRank #595 · 4K reputationPosted Jan 14, 2015, 6:51 AM EST
Find the query below
SELECT ID, MONTHNAME('2001-' + Month + '-01') AS mnth
FROM table
Hope this answers your question.