February 21, 2012 at 11:52 am
select @col = COALESCE(@col + ',','')+ QUOTENAME(Datename(month,work_date ))
from form_Details WHERE Work_Date between '2012-01-01' and '2012-02-28'
GROUP BY Datename(month,work_date)
ORDER BY Datename(month,work_date) DESC
print @col
CREATE TABLE #cmd_holiday (@col float ) --> i want like this dynamic (January float ,February Float)
INSERT #cmd_holiday
execute [GetHolidaySumNewHours] '2012-01-01','2012-02-28'
select * from #cmd_holiday
any way to solve this please !
February 21, 2012 at 12:07 pm
You may have to use Global Temp Tables or persisted tables to do that.. If you need your column names to be dynamically included in the CREATE Table clause, you will have to use dynamic SQL.
As a side bar, what is the output of [GetHolidaySumNewHours] ? What column names does this SP output?
February 21, 2012 at 12:14 pm
First of all
CREATE TABLE #cmd_holiday (@col float ) --> i want like this dynamic (January float ,February Float)
-- should be
--CREATE TABLE #cmd_holiday (col float )
Second we have no idea what this does
INSERT #cmd_holiday
execute [GetHolidaySumNewHours] '2012-01-01','2012-02-28'
select * from #cmd_holiday
Can you post some sample data returned by the SP GetHolidaySumNewHours
To do this quickly and easily please read the article which is in the first link in my signature block. With that information some one may be able to assist you with a tested solution.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply