I'm trying to help a friend at work figure this one out. Here's the situation. He has the table below:
What we need to do is query the table and create one output record for each Type. However, the output record needs to contain Type and a bit string set by looking at Value.
Output Ex:
A1001010 (bit string is all 0, except for pos 1, 4, & 6)
B0110001 (bit string is all 0, except for pos 2, 3, & 7)
This file is getting passed to a mainframe program that is expecting the output in the format above. The actual output variable will have over 200 places in it.
I can't think of a way to do this with just plain Ole SQL. Is there a function or something that can be used to replace a single character in a string? I know in VB, ColdFusion, etc. there are functions that will allow one to change all/part of a string. If there is, I think we should be able to partition by Type and replace each character at the Value position with a 1.
As always, your help is appreciated!!!
Thanks,
Doug
Code:
Type Value
A 1
A 4
A 6
B 2
B 3
B 7
What we need to do is query the table and create one output record for each Type. However, the output record needs to contain Type and a bit string set by looking at Value.
Output Ex:
A1001010 (bit string is all 0, except for pos 1, 4, & 6)
B0110001 (bit string is all 0, except for pos 2, 3, & 7)
This file is getting passed to a mainframe program that is expecting the output in the format above. The actual output variable will have over 200 places in it.
I can't think of a way to do this with just plain Ole SQL. Is there a function or something that can be used to replace a single character in a string? I know in VB, ColdFusion, etc. there are functions that will allow one to change all/part of a string. If there is, I think we should be able to partition by Type and replace each character at the Value position with a 1.
As always, your help is appreciated!!!
Thanks,
Doug