Advertisement
Guest User

Untitled

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