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

I need to replace old path's images to new path with the same image

I have a column Path_Image in table DBPaths :

 Path_Image          
 C:\Users\Pc\Desktop\archive\1.png
 D:\pics_back\22.jpg
 C:\Users\Pc\Desktop\archive\947141.JPG

And I have a new Path:

E:\pics2024

I want to replace all old paths with a new one without touch images , like this :

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

 Path_Image
 E:\pics2024\1.png
 E:\pics2024\22.jpg
 E:\pics2024\947141.JPG

The question is that possible and how I can do it , for me no idea how it could be?

>Solution :

I have little experience with string functions, so the code below is just a rough idea

WITH your_table(PATH_IMAGE)AS
(  
  SELECT ' C:\Users\Pc\Desktop\archive\1.png' UNION ALL
  SELECT 'D:\pics_back\22.jpg' UNION ALL
  SELECT 'C:\Users\Pc\Desktop\archive\947141.JPG'
)
SELECT C.PATH_IMAGE,'E:\pics2024'+RIGHT(C.PATH_IMAGE,CHARINDEX('\',REVERSE(C.PATH_IMAGE)))
FROM your_table AS C
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