SDU Tools: Extracting file path components in SQL Server T-SQL

SDU Tools: Extracting file path components in SQL Server T-SQL

Our free SDU Tools for developers and DBAs, now includes a very large number of tools, with procedures, functions, and views. One common request that we’ve had, is that users need to be able to extract the component parts of a file path.

In the example above, you’ll see that we have added a table-valued function called FilePathComponents.

It supports both drive paths and UNC paths.

In case, you need to process individual paths, to help with that, we’ve added a number of scalar functions: FilePathToFileName, FilePathToFolderName, FilePathToFileExtension. You can see them in action here:

File path functions example

Find out more

You can see it in action in the main image above, and in the video here:

YouTube Video

And the video covering the individual functions is here:

YouTube Video

You can use our tools as a set or as a great example of how to write functions like these.

Access to SDU Tools is one of the benefits of being an SDU Insider, along with access to our other free tools and eBooks. Please just visit here for more info:

http://sdutools.sqldownunder.com

2025-04-10