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 |
|
klee
Starting Member
2 Posts |
Posted - 2011-04-01 : 18:57:49
|
| Hello,I have this db that has 2 columns namely field_name (contains header info) and mask (contains actual data). Question is how can I get present the data in excel or something in the proper format by traversing field_name and populating mask data into the appropriate field_name column? Not sure if this makes sense at all.EG data in sqlCust_No | FieldName | MaskABC ACC # 1234ABC ACC Name ABC CorpABC City xxxxDEF ACC # 5678DEF ACC Name DEF CorpDEF City yyyyLike to haveCust_No | ACC # | ACC Name | CityABC mask valThanks,Kev |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
klee
Starting Member
2 Posts |
Posted - 2011-04-01 : 19:09:43
|
| I've tried pivot. Unless i'm doing something wrong, I can't get the mask data to display. It does the count/sum/etc. |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-01 : 20:22:00
|
If you were trying to use the PIVOT keyword, there are couple of things that can cause it to not work.1. You have to be using SQL 2005 or higher.2. Compatibility level of your database should be 90 or higher.If those are true, then the following should work:select *from YourTablepivot ( max(Mask) for FieldName in ( [ACC @],[ACC Name],[City]))P I wrote it out very carefully, it parses, but I have not tested it. |
 |
|
|
|
|
|