July 22, 2010 at 1:24 pm
I have 3 columns. The output of the stored procedure look like below...
Month Total HoursUtilizedleft out
Jan 200 xxx yyy
Feb 200 xxx yyy
Mar 200 xxx yyy
Apr 200 xxx yyy
May 200 xxx yyy
Jun 200 xxx yyy
Jul 200 xxx yyy
Using this i generate a crystal report, But i need the out put to be the following format.
Jan feb mar apr may jun jul
Total Hours 200 200 200 200 200 200 200
utilized xxx xxx xxx xxx xxx xxx xxx
left out yyy yyy yyy yyy yyy yyy yyy
How to achieve this?
Thanks in advance
[font="Courier New"]Deepan[/font]
July 23, 2010 at 8:12 am
modify your stored procedure and add a PIVOT
--------------------------
I long for a job where my databases dont have any pesky users accessing them 🙂
July 23, 2010 at 8:18 am
Can you elaborate it, because I am bit new to SP. Even a reference, model or example of those will help me a lot
[font="Courier New"]Deepan[/font]
July 23, 2010 at 8:26 am
Sure
right click your stored procedure and click Script Stored Procedure As - then pick ALTER To - Then pick new query window
This will display your stored procedure - you can now modify it, and when you run the script it will update your stored procedure. I would recommend changing the name of it so you have a copy of the stored procedure and are not working with the original.
You then want to modify your select statement to include a pivot - heres a tutorial on pivot
http://www.kodyaz.com/articles/t-sql-pivot-tables-in-sql-server-tutorial-with-examples.aspx
Hope that helps
--------------------------
I long for a job where my databases dont have any pesky users accessing them 🙂
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply