May 14, 2008 at 11:27 pm
Check this out...
Declare @sSqlC varchar(1000)
select @sSqlC = COALESCE(@sSqlC + ',','') + ' ''' + cast(tblDating.[Date] as varchar(20)) + ''' As Col' + cast(tblDating.id as varchar) from tblDating
set @sSqlC = 'Select ' + @sSqlC
--Select @sSqlC
Exec(@sSqlC)
Thanks
Atif Sheikh
December 27, 2008 at 4:31 am
plz Check this...
I think it is useful for you
declare @lsstr as varchar(750)
declare @lssql as varchar(500)
set @lsstr = ''
select @lsstr = @lsstr + ',[' + 'C' + convert(varchar(5),row_number() over(order by date)) + ']' from dating
set @lsstr = substring(@lsstr,2,len(@lsstr))
select @lsstr
set @lssql = 'select ' + @lsstr + ' from '
set @lssql = @lssql + '(select ''C'' + convert(varchar(5),row_number() over(order by date)) slno,date from dating ) a '
set @lssql = @lssql + 'pivot (max(date) for slno in (' + @lsstr + ')) as p '
print @lssql
exec(@lssql)
March 3, 2009 at 3:19 am
Me too in need of same kind of requirement....help pls...
March 4, 2009 at 12:04 am
bhuvaneshwari_m (3/3/2009)
Me too in need of same kind of requirement....help pls...
http://www.sqlservercentral.com/articles/cross+tab/65048/
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 31 through 33 (of 33 total)
You must be logged in to reply to this topic. Login to reply