SHARE
TWEET

Untitled

a guest Jun 18th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top