user2735206
user2735206

Reputation: 67

Replace with like

I have an ms sql table with brief_n as a column which holds records like this

xx/xx/xx: Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed di where xx/xx/xx is the corresponding date. How do I get rid of all the date and just have

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed di.

I am not sure what goes into the replace field.

UPDATE tablename.dbo.news
SET brief_n = REPLACE (brief_n,'','')
WHERE brief_n LIKE '--/--/--'

Upvotes: 1

Views: 2853

Answers (2)

Vineeth Vijayan
Vineeth Vijayan

Reputation: 1329

if all the string is in the same format as u said u can use substring

substring(brief_n,11, len(brief_n))

Hope it helps.

Upvotes: 0

dani herrera
dani herrera

Reputation: 51705

This is your query:

UPDATE tablename.dbo.news
SET brief_n = substring(brief_n,10,4000)
WHERE brief_n LIKE '__/__/__:%'

Explanation: Truncate first 10 chars for all rows starting with '__/__/__:'.

Upvotes: 1

Related Questions