Assistance with SQL statement

Brass Contributor

Hi, Does anyone have any suggestions for this?

 

Chris

---------------------------------------

 

Hi  Apology if this is the wrong forum, I am new to SQL and I would normally be doing this operation through Excel PowerQuery but its keeps crashing, so I thought I would give this a try.

 

So my rawdata comes from an SQL View, I use Excel to import this data and through Excel I can issue SQL commands/statements to manipulate what columns I want.  I have limited SQL experience I can extract some detail but not to this level.  

 

Step 1; my raw data, I am needing to extract all the 6 digit codes from the column called 'IN_CODE'.  

Step1 Codes are all 6 digits length, there also extra spaces between codes
PROJECT_IDPROJECT_TITLEIN_CODE
1246NAME2R12345 and    R45647, RA4564 & RB4561
1261NAME3R12478
1276NAME4R12457,
1291NAME5RA4789
1306NAME6TY7894
1321NAME7FG5674
1336NAME8R45789 ,   TY7894
1351NAME9R13445 R78456 & R96325 (SCCA) R44557 (Dept) R77889 R11122
1366NAME10RT7845
1381NAME11RT1234

 

Step 2, I then want to remove all unwanted text, e.g. 'and' ',', '&' '(SCCA)' etc  There are also extra spaces just for a good measure. 

Step2 Codes are all 6 digits length, there also extra spaces between codes
PROJECT_IDPROJECT_TITLEIN_CODE
1246NAME2R12345 R45647    RA4564 RB4561
1261NAME3R12478
1276NAME4R12457
1291NAME5RA4789
1306NAME6TY7894
1321NAME7FG5674
1336NAME8R45789 TY7894
1351NAME9R13445 R78456 R96325 R44557 R77889 R11122
1366NAME10RT7845
1381NAME11RT1234

 

Step 3, so I want to get the data from step 1 to look like this - 

Step3  
PROJECT_IDPROJECT_TITLEIN_CODE
1246NAME2R12345
1246NAME2R45647
1246NAME2RA4564
1246NAME2RB4561
1261NAME3R12478
1276NAME4R12457
1291NAME5RA4789
1306NAME6TY7894
1321NAME7FG5674
1336NAME8R45789
1336NAME8TY7894
1351NAME9R13445
1351NAME9R78456
1351NAME9R96325
1351NAME9R44557
1351NAME9R77889
1351NAME9R11122
1366NAME10RT7845
1381NAME11RT1234

 

Any help appreciated.

 

Chris C

0 Replies