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 |
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-11-19 : 16:23:20
|
| The sql ret is in t1.date col1 col211/1/07 2 311/2/0711/5/0711/6/0711/7/0711/8/0711/9/0711/12/07----11/19/07I want tranpose it to t2date 11/1/07 11/2/07 11/5/07 11/6/07 11/7/07 11/8/07 11/9/07-11/12/07Q1 2Q2 3The date does not include weekends. I need to run it every day so the records in t1 keep on increasing by 1 every weekday.How can I do it? I have sql query anlyzer 2000Thanks |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2007-11-19 : 18:47:59
|
create the linked procedure and you can use that to simulate a PIVOT function in SQL 2000 (Pivot available in SQL 2005, but you indicate SQL 2000)If your SQL server is a 2005 box, look at the PIVOT function in BOL for SQL 2005.http://media.techtarget.com/digitalguide/images/Misc/sp_Crosstab.txt Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-20 : 01:35:18
|
| Also if you want to present your data in reports, make use of it's cross-tab featureMadhivananFailing to plan is Planning to fail |
 |
|
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-11-20 : 08:08:51
|
| Thanks,The trouble is I do not have right to create a precdure in the query analyzer.Is there a solution to that?Jeff |
 |
|
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-11-20 : 08:26:42
|
| My table also have a id colume, thanksThe sql ret is in t1.id date col1 col21 11/1/07 2 32 11/2/073 11/5/074 11/6/075 11/7/076 11/8/077 11/9/078 11/12/07----20 11/19/07I want tranpose it to t2id 1 2 3 4 5 6 7 ---------------- 20date 11/1/07 11/2/07 11/5/07 11/6/07 11/7/07 11/8/07 11/9/07-11/12/07Q1 2Q2 3 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-20 : 08:29:19
|
you posted in a SQL Server 2005 forum but you state "I have sql query anlyzer 2000". If you are using SQL Server 2005, use the PIVOT function to do it. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-11-20 : 08:49:55
|
| Sorry I never realized sql server 2000 and 2005 are in different forum.I have started a new thread in sql server 2000 and I do not know how to delete this thread.Thanks |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-20 : 08:57:46
|
you can't delete it once there are replies to the thread KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|