|
sqlnovice1
Starting Member
34 Posts |
Posted - 2011-08-04 : 05:29:27
|
| HiI have a problem at work (a hospital). We have data stored in a DWH that is taken from an overnight snapshot from the live sysytem and resides in a view in SQL server.I have a column from the live system which contains multiple data items seperated by a '/'.i need to show this field as seperate columns (up to a max of 10)Below is an example of my data and also an expected results table.Any help or advice would be greatly appreciated --Data I have to work with --CREATE TABLE PS_TestForOnline( crn NVARCHAR (10), all_codes_in_one_field VARCHAR (500),);INSERT INTO PS_TestForOnlineVALUES('11111','W83.1, Endoscopic drilling of lesion of articular cartilage / Y76.7, Arthroscopic approach to joint / W74.2, Reconstruction of intra-articular ligament NEC / Y69.8, Other specified harvest of other tissue' );INSERT INTO PS_TestForOnlineVALUES('22222','W28.3, Removal of internal fixation from bone NEC / W31.9, Unspecified other autograft of bone / W62.9, Unspecified other primary fusion of other joint' );INSERT INTO PS_TestForOnlineVALUES('33333','L62.1, Repair of femoral artery NEC' );INSERT INTO PS_TestForOnlineVALUES('44444','E13.6, Puncture of maxillary antrum / E08.1, Polypectomy of internal nose' );select * from PS_TestForOnlinedrop table PS_TestForOnline------------------------------------------------------------Expected results--CREATE TABLE PS_TestForOnline_expected_answer( crn int, CODE_POS_1 NVARCHAR (500), CODE_POS_2 NVARCHAR (500), CODE_POS_3 NVARCHAR (500), CODE_POS_4 NVARCHAR (500), CODE_POS_5 NVARCHAR (500), CODE_POS_6 NVARCHAR (500), CODE_POS_7 NVARCHAR (500), CODE_POS_8 NVARCHAR (500), CODE_POS_9 NVARCHAR (500), CODE_POS_10 NVARCHAR (500),);INSERT INTO PS_TestForOnline_expected_answerVALUES('11111','W83.1, Endoscopic drilling of lesion of articular cartilage','Y76.7, Arthroscopic approach to joint','W74.2, Reconstruction of intra-articular ligament NEC','Y69.8, Other specified harvest of other tissue','','','','','','');INSERT INTO PS_TestForOnline_expected_answerVALUES('22222','W28.3, Removal of internal fixation from bone NEC','W31.9, Unspecified other autograft of bone','W62.9, Unspecified other primary fusion of other joint','','','','','','','' );INSERT INTO PS_TestForOnline_expected_answerVALUES('33333','L62.1, Repair of femoral artery NEC','','','','','','','','','' );INSERT INTO PS_TestForOnline_expected_answerVALUES('44444','E13.6, Puncture of maxillary antrum','E08.1, Polypectomy of internal nose','','','','','','','','' );select * from PS_TestForOnline_expected_answerdrop table PS_TestForOnline_expected_answerPaul |
|