Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically setting column name ...?

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
Can SQL Syntax be used to dynamically set column names?
Let's say for instance today's date is 11/12/2006 - and I can therefore derive the corresponding month name - setting this up as a variable, i.e. using syntax:

declare @CurrDate datetime
SET @CurrDate = GetDate()
declare @CurrMonth varchar(12)
SET @CurrMonth = DATENAME(month, @CurrDate)
SELECT @CurrDate
SELECT @CurrMonth

Can I use this @CurrMonth variable then in a column name - i.e. calling a column 'December' (albeit this being set according to the current month - as above).

How easily is this done?
Can it be?

Any help be greatly appreciated.
Thanks in advance,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top