Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Convert full path to filename.
- -- i.e. \\mycompany.com\bigshare\apps\MyApp\outbound\ClientID\ReportType.ClientID.20190529.csv
- -- to ReportType.ClientID.20190529.csv
- DECLARE @searchFromRight VARCHAR(MAX) = REVERSE(@filename);
- DECLARE @pathCharIndex BIGINT = COALESCE(CHARINDEX('\', @searchFromRight), CHARINDEX('/', @searchFromRight), 0);
- --IF NOT (@pathCharIndex BETWEEN 27 AND 60)
- -- THROW 51000, 'Could not convert full path to filename.', 1;
- SET @filename = SUBSTRING(@filename, LEN(@filename) - @pathCharIndex + 2, @pathCharIndex - 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement