Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Parsing Non Numeric Range

$
0
0

I have a list of code ranges as follow.

3-7 characters in length, Digit 1 is alpha; digit 2 is numeric, digit 3 is numeric/alpha; digits 4-7 are alpha or numeric

The range seems to increment in digit 4-7.

The tabe field looks like the following

SELECT 'A34' AS CodeRange UNION ALL
SELECT 'D700-D704' UNION ALL
SELECT 'M1A10X0-M1A10X1' UNION ALL
SELECT 'M1A1290-M1A1291' UNION ALL
SELECT 'O409XX0-O409XX5' 

How can I parse the column into a single code column like below?

SELECT 'A34' AS SingleCode UNION ALL
SELECT 'D700' UNION ALL
SELECT 'D701' UNION ALL
SELECT 'D702' UNION ALL
SELECT 'D703' UNION ALL 
SELECT 'D704' UNION ALL 
SELECT 'M1A10X0' UNION ALL
SELECT 'M1A10X1' UNION ALL 
SELECT 'M1A1290' UNION ALL 
SELECT 'M1A1291' UNION ALL 
SELECT 'O409XX0' UNION ALL 
SELECT 'O409XX1' UNION ALL  
SELECT 'O409XX2' UNION ALL  
SELECT 'O409XX3' UNION ALL  
SELECT 'O409XX4' UNION ALL 
SELECT 'O409XX5'

Please advise.



Viewing all articles
Browse latest Browse all 23857

Trending Articles