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 |
|
vmurali
Yak Posting Veteran
88 Posts |
Posted - 2007-01-17 : 06:22:35
|
| tblname rowno colname colvalueemp 1 Title Mremp 1 firstname XYZemp 1 lastname MI want to get astitle first_name lastnameMr XYZ M |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-17 : 06:27:35
|
| [code]-- prepare sample datadeclare @t table (tblname varchar(3), rowno tinyint, colname varchar(9), colvalue varchar(3))insert @tselect 'emp', 1, 'Title', 'Mr' union allselect 'emp', 1, 'firstname', 'XYZ' union allselect 'emp', 1, 'lastname', 'M'-- show the resultselect max(case when colname = 'title' then colvalue end) as Title, max(case when colname = 'firstname' then colvalue end) as FirstName, max(case when colname = 'lastname' then colvalue end) as LastNamefrom @tgroup by rowno[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|