Thursday, 15 September 2016

Get file name from file path in SQL

Get file name from file path in SQL

Description:


In this example we explain that how to Get file name from file full path in SQL Server.or hoe to fetch the file name from the SQL Server.as we know that we will store the full path of the file in SQL Server so how can I fetch the only file name from the SQL Server.below is the SQL Query that will fetch the file name from the full path in SQL Server.

The below query return the file name like “Customer.xlxs”
Query:

DECLARE @fullpath VARCHAR(1000)
SET @fullpath = 'D:\Projects\UploadFiles\Customers.xlsx'

SELECT  RIGHT(@fullpath, CHARINDEX('\', REVERSE(@fullpath)) - 1)
This entry was posted in :

0 comments:

Post a Comment