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
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