Reputation: 43
I want to update the table by removing some text in the table. For example,
Table field data is: "I Like Trees", "I Like Fruits", "I Like Songs"
I want to make it as on occurrence of Like I want to remove all after with "Like", Output should be as, "I ", "I ", "I "
Any help, please?
Upvotes: 2
Views: 58
Reputation: 4620
Update table
set col = SUBSTRING(col,1,CHARINDEX('LIKE',col,0)-1)
where column like '%Like%'
Upvotes: 0
Reputation: 11205
Try:
UPDATE MyTable
set MyField = substring(MyField, 1, INSTR(MyField, 'Like')-1)
where MyField like '%Like%'
Upvotes: 1