Skip to content

Instantly share code, notes, and snippets.

@amtwo
Last active January 17, 2018 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amtwo/a03ef4906153a007f08c81101dfc6167 to your computer and use it in GitHub Desktop.
Save amtwo/a03ef4906153a007f08c81101dfc6167 to your computer and use it in GitHub Desktop.
Step 2) Parsing the file & path from the full path.
DECLARE @FilePath nvarchar(300) = N'C:\Users\Andy\Documents\GitHub\dba-database\stored-procedures\dbo.Alert_Blocking.sql';
WITH ParseInfo AS(
SELECT FilePath = @FilePath,
PathLen = LEN(@FilePath),
FinalSlashPos = CHARINDEX('\', REVERSE(@FilePath), 1)
)
SELECT DirectoryPath = LEFT (FilePath, PathLen - FinalSlashPos + 1),
FullFileName = RIGHT(FilePath, FinalSlashPos - 1),
*
FROM ParseInfo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment