-2

I have the following table called DQS_Raw with two columns.

DQS_Raw

id    Result
-----------------    
1   |01|00|00|01
2   |00|01|01|00
3   |00|00|00|01

I need to use a stored procedure to get the below table result.

The below table has 6 columns.

DQS_Raw

id  Result        VF02a VF02b VF02c VF05b
------------------------------------------    
1   |01|00|00|01  01    00    00    01
2   |00|01|01|00  00    01    01    00
3   |00|00|00|01  00    00    00    01

As noted here the values between the pipe delimited characters are extracted. The first extracted values are assigned to the column VF02a, the second assigned to VF02b and so on.

I also need this to be dynamic enough in case the order changes from the input.

Please don't use a set based approach.

Jono

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

I think it would be impossible to make this a dynamic approach.

But you can do something like this to split the value

I assume your using ssms 2010 server

select *,  
SUBSTRING(Result,2,2) as VF021,  
SUBSTRING(Result,5,2) as VF02b,  
SUBSTRING(Result,8,2) as VF02c,  
SUBSTRING(Result,11,2) as VF05b  
from DQS_RAW
Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71
zxc
  • 1,504
  • 3
  • 13
  • 32