Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
stompkins@sycuan.com
Starting Member
4 Posts |
Posted - 2008-08-26 : 15:22:50
|
I'm providing a user with a report on accounts with activity by month for the previous 6 months. By pulling the month out of the activity date, I want to use it in the column headers.For example, if I kick off the query on 8/4, the results should be similar toID February March April May June Julyxxx 12345 1254 4521 4521 541 4587The headers change dynamically, depending on when the query is run. I'm trying to use datename(month, activitydate) to pull in the month name, but can't figure out how to get it into the header. Any suggestions??? |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-08-26 : 15:29:52
|
Why not do it at the presentation layer?"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
|
|
stompkins@sycuan.com
Starting Member
4 Posts |
Posted - 2008-08-26 : 16:11:25
|
I never see the report at presentation level. Once the sql is coded, the end user kicks it off from a menu and it dumps right into a spreadsheet for him. I'll need the sql to take care of generating the headers. |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-08-26 : 16:12:43
|
What is generating the spread sheet?"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
|
|
stompkins@sycuan.com
Starting Member
4 Posts |
Posted - 2008-08-26 : 16:16:23
|
We have some code written in vb.net that provides a front end interface to our end users. It handles the back-end interface with excel. I don't want to change the code in the .net world as we have literally thousands of reports being generated through it. |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-08-26 : 16:21:43
|
Then look into dynamic SQL, but it is a bad idea, this should be done in the .net code."God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
|
|
stompkins@sycuan.com
Starting Member
4 Posts |
Posted - 2008-08-26 : 16:35:25
|
so... what I'm wanting to do, can't be done through sql? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-27 : 00:06:20
|
this is called cross tabing. try with any of methods belowhttp://www.mssqltips.com/tip.asp?tip=937 |
|
|
|
|
|
|
|