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 |
|
omega1983
Starting Member
40 Posts |
Posted - 2008-02-07 : 10:26:59
|
| In sql server, multiple instances of data default to a row display or vertical. I need a set of data in sql2005 to view horizontally so I can us it in a crystal report. Here is my issue.gift.HonorKey, gift.HonorName, gift.HonorId1211 Smith 12221244 Owens 4155I need for the data to read like this:HonorKey1, HonorKey2, HonorName1, HonorName2, HonorId1, Honorid21211 1244 Smith Owens 1222 4155the table name is gift_viewI would like to be able to create a view in sql analyzer, then save as an SQL ViewMy direct email is jackfam@comcast.net |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-07 : 10:32:44
|
Good for you!If we only care about the task in mind, you can use PIVOT or CROSSTAB algorithm to accomplish this.In SQL Server 2005 there is a built-in PIVOT operator to use! E 12°55'05.25"N 56°04'39.16" |
 |
|
|
omega1983
Starting Member
40 Posts |
Posted - 2008-02-07 : 10:58:20
|
| Msg 325, Level 15, State 1, Line 12Incorrect syntax near 'pivot'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel.This is the error msg I get. I used the following code (modified for security)select giftkey,giftid,gifthonorfrom gifts_viewwhere gifthonor is not nullpivotI am doing a simple VIEW here. Is there a workaround the error message I received??? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-07 : 11:18:09
|
| select giftkey,giftid,gifthonorfrom gifts_viewwhere gifthonor is not nullpivot??where's rest of code?Did you refer to syntax of PIVOT in BOL?You need to tell it what to pivot on.Try it out yourself and let us know if you face any problem. |
 |
|
|
|
|
|
|
|