Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I update column in SQL by removing preceding characters in column?

I need help in updating records in my table [Fruit]. Currently, I have number – name (ie 1234 - Apple) value which I would like to replace with Apple from all the records (the number preceding is not the same).

Date       ItemNo    Fruit   
---------------------------------
01/10/10   1234      1234 - Apple
01/12/10   5546      5546 - Banana   

I want to only remove the preceding number - from the column Fruit.

Date       ItemNo    Fruit   
---------------------------------
01/10/10   1234      Apple
01/12/10   5546      Banana  

How do I do this for all rows in my table?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

How about the following:

update t set fruit=Replace(fruit, Concat(itemno, ' - '),'')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading