I am writing a procedure in order to handle a file name in SSIS.
Overview:
I am capturing the file name during a Text file load process in SSIS. I have written a procedure in order to split this file name into different components and return the values in form of Variables which I would be using further down the SSIS package.
Problem
This file name is of the format @FileName ="FILE_DATE_REF_DATETIME".All I need
to split this in a way like "FILE" , "DATE". I am able to achieve this by using
SUBSTRING(@Filename,0,CHARINDEX('_',@FileName))
and
Substring(@FileName,CHARINDEX('_',@FileName)+1,CHARINDEX('_',SUBSTRING(@Filename,CHARINDEX('_',@Filename)+1,Len(@Filename)))-1)
But here the major problem is when we get an additional '_' in FILE it completely goes wrong. Can anyone please suggest a way that I split the above file name format into FILE and DATE.
EDIT
Samples of FileNames:
asdfkg_20140710_ets20140710_0525_theds
asdjjf_they_20140710_ets20140710_0525_theds
oiuth_theyb_wgb_20140710_ets20140710_0526_theds
I need to extract anything before the 20140710 and also 20140710.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句