TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anurag Srivastava
NA
39
0
Want to show Dynamic column name in SQL SERVER 2008
Jul 5 2012 7:57 AM
Hello All
I have a problem
I want to show Column name like 'Jan-2010','Feb-2010' and so on.
declare @Year int = 2012
declare @a varchar(20)
set @a= CAST('jan-' as varchar(20))+ Cast(@Year as Varchar(20))
print @a
select ColumnName as @a
The 'Jan-','Feb-','Mar-' are hard coded, but year should come dynamically.
and column name should appear like 'Jan-2010','Feb-2010' if Year is 2010,
if Year is 2011, it should show like 'Jan-2011','Feb-2011' and so on.
Pls help as soon as possible.
Thanks in Advance.
Regards
Anurag
Reply
Answers (
2
)
Data Validation on Stored Procedure in SQL Server
sqlserver