I have a column in a table that stores the full pathname for files, ie. C:\folder1\folder2\folder3\myfile.htm
What I want to do is to update all these pathnames to just be the filename only, ie. myfile.htm
The pathnames could be different levels of subfolders before the filename. So what I really need is keep everything after the last "\" in the stored path. Is there a way to do this in an update query? Thanks.
, Reverse(full_path) As reverse_it
, CharIndex('\', Reverse(full_path)) As last_slash
, Len(full_path) As string_length
/* string_length - last_period + 2 */
, SubString(full_path, Len(full_path) - CharIndex('\', Reverse(full_path)) + 2, 1000) As filename
FROM (SELECT 'C:\folder1\folder2\folder3\myfile.htm' As full_path) As x
Last edited by gvee; 08-23-13 at 15:50.
Reason: Misread question