Link to home
Start Free TrialLog in
Avatar of RVL
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
Avatar of awking00
awking00
Flag of United States of America image

A few questions. Does the portion with the "ID" value always come at the beginning or not?
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.
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'))

Open in new window

Avatar of RVL
RVL

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).
Avatar of RVL

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
SOLUTION
Avatar of Surendra Nath
Surendra Nath
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial