I need to parse file name and file path from full path using SQL Query.
Eg. Fullpath - \SERVER\D$\EXPORTFILES\EXPORT001.csv
FileName Path
EXPORT001.csv \\SERVER\D$\EXPORTFILES\
I need to parse file name and file path from full path using SQL Query.
Eg. Fullpath - \SERVER\D$\EXPORTFILES\EXPORT001.csv
FileName Path
EXPORT001.csv \\SERVER\D$\EXPORTFILES\
Answer based on comment by Stefan Steiger:
Test code:
Here is the simplest way
Here's a link where someone made several functions related to this need:
http://www.codeproject.com/Tips/866934/Extracting-the-filename-from-a-full-path-in-SQL-Se?msg=5145303#xx5145303xx
Use this -
I do a lot of ETL work and I was looking for a function that I could use and qub1n's solution works very good except for values without a back slash. Here is a little tweak of qub1n's solution that will handle strings without back slashes:
Samples:
Here is a LINK to SqlFiddle