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 |
|
bconner
Starting Member
48 Posts |
Posted - 2011-06-16 : 12:43:38
|
| I have data stored in a table like below:Patient Specimen Part(s); CPT Code(s)SMELTZER, MICHAEL TED 88173; 88305CBELLER, MARION JOYCE 88173; 88172; 88172; 88305CBIs there a way to pull it like this:Patient Specimen Part(s); CPT Code(s)SMELTZER, MICHAEL TED 88173SMELTZER, MICHAEL TED 88305CBELLER, MARION JOYCE 88173ELLER, MARION JOYCE 88172ELLER, MARION JOYCE 88172ELLER, MARION JOYCE 88305CBBrian |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-06-16 : 13:04:21
|
| Search this site for the ParseValues functionDECLARE @table table (string varchar(40))INSERT INTO @table select 'SMELTZER, MICHAEL TED 88173; 88305CB'select left(string,patindex('%[0-9]%',string)-1),a.valfrom@tablecross apply ( select val from dbo.ParseValues(substring(string,patindex('%[0-9]%',string),charindex(';',string)),';'))aJimEveryday I learn something that somebody else already knew |
 |
|
|
bconner
Starting Member
48 Posts |
Posted - 2011-06-16 : 14:50:51
|
| Thanks JimBrian |
 |
|
|
|
|
|
|
|