Getting or extracting the physical path using Sql Query.

Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 308
Declare @physical_path varchar(1000) = 'C:\Images\img_view.png';
SELECT LEFT(@physical_path,LEN(@physical_path) - CHARINDEX('\',REVERSE(@physical_path))) as physical_path_only


It finds the position of last slash ('\') in the path using CHARINDEX and Reverse string,and then cuts everything up to that point with the help of LEFT function.

Comments or Responses

Login to post response