prakashdotc (12/21/2008)
Hi All,I already have a query which retrieve data based on various dates, now i need is the Column header with those 'Date'.
Dynamic Dates as Column Header.
Is there any way to do this SQL Server 2005.
Thanks in Advance.
Prakash.C
Thsi is a sample only
declare @colname varchar(100)
declare @rowcolname varchar(1000)
set @rowcolname = ''
declare col CURSOR FOR
select id from actionstate
open col
fetch next from col into @colname
while @@fetch_status = 0
begin
set @rowcolname = @rowcolname + '[' + @colname + '] int,'
fetch next from col into @colname
end
close col
deallocate col
print('Create TAble tablename('+ @rowcolname + ')')
exec('Create TAble tablename('+ @rowcolname + ')')
select * from tablename
drop tablename
kshitij kumar
kshitij@krayknot.com
www.krayknot.com