![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi David, Try the following: Create table t1 (ID int, kw_name char(03), kw_value char(02)) -- My version of your table. select ID, "NAME"=max(substring(kw_value,1,3*(charindex('NAM' ,kw_name)))), "NUM"=max(substring(kw_value,1,2*(charindex('NUM', kw_name)))) from t1 group by ID go ID NAME NUM ----------- ---- --- 1 a1 b1 2 a2 b2 3 a3 b3 (3 rows affected) For variable length columns substitute 'datalength(kw_value)' for the hard-coded '2' and '3' above ... I think this table pivot is what you are looking for ... Good Luck, Sara ... |
![]() |
| Thread Tools | |
| Display Modes | |
| |