SQL Statement to Update Where Description Contains "x"

Aug 24, 2006 3 Replies

I would like to do a SQL statement to update th SubDescription1 field to be a value if the Description contains a particular string.



For example (not a valid statement):



UPDATE Item SET SubDescription3 = '2807.01.90' WHERE Description CONTAINS 'Screw'



I am not SQL expert, but there must be something like this that will work... Any advice appreciated. (and yes, I know, backup the database before running any SQL UPDATE statement).



Jason


You need to run:

UPDATE Item SET SubDescription3 = '2807.01.90' WHERE Description like '%Screw%'

I suggest a SELECT first to see what rows you will be updating:

SELECT SubDescription3, * FROM Item WHERE Description like '%Screw%'

Cheers Martin

Wonderful. I knew there was a way... Like, not Contains...

Is capitalizati> You need to run:

not in a default install. By default SQL Server is set up to be case insensitive...

Glenn Adams Tiber Creek C> Wonderful. I knew there was a way... Like, not Contains...

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required