I have a table that contains a column for images which stores the link of images.
The example looks like this:
\Images/image1.jpg
Now assume my database has more than 1000 records for 1000 images which is working fine, but now due to some requirement change, I have to update the links.
I want to remove the first slash from the all 1000 records via a SQL query.
Now it is stored like this:
\Images/image1.jpg
and I want to convert it to
Images/image1.jpg
One approach is to go to 1000 records and remove it one by one, which is too time consuming, as an alternative what could be a SQL query that could be run via SSMS?
Advertisement
Answer
You can use REPLACE
to do this:
update yourTable set yourColumn = replace(yourColumn,'\','')