RVL
asked on
move to another column
Hi,
i would like to move one size to another column based on the word "ID"
eg
before
size
0.3750" ID x 0.8750" OD x 0.2188" WD
after
size attrib1
0.8750" OD x 0.2188" WD 0.3750" ID
Thanks
i would like to move one size to another column based on the word "ID"
eg
before
size
0.3750" ID x 0.8750" OD x 0.2188" WD
after
size attrib1
0.8750" OD x 0.2188" WD 0.3750" ID
Thanks
try this out
DECLARE @T VARCHAR(1000)
SET @T = '0.3750" ID x 0.8750" OD x 0.2188" WD'
select @T
select substring(@t,charindex('ID x',@T) + len('ID x'),len(@t)-(charindex('ID x',@T) + len('ID x'))), substring(@t,0,charindex('ID x',@T) + len('ID x'))
ASKER
it's not always in the beginning and may not always follow by a X and yes attrib1 exists
So can I assume the x stands for "times" and, if the ID measurement is the last, it wouldn't be followed by the x. Conversely, if ID is in the middle, it would be both preceded and succeded by the x. The next question is, "Do all of the measurements take the same format?" In your example, they all begin with 0 followed by a decimal point and four digits then a double quote (I assume stands for inches).
ASKER
yes depends were the ID is it could only be 0.3750" ID in the column, could have 12.3750" ID
or 7 MM ID
or 7 MM ID
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is it always followed by the "x" which gets eliminated in the transformation? Does the column attrib1 already exist? Can "ID" occur more than once? Perhaps some sample data that includes the various criteria and the expected final results would be helpful.