How to create Flat File with Date

  • Hi,

    Need to generate flat file using SSIS.

    I have created packages and files were generated in a sepcific folder with current date.

    If i executed the package five times today, it created only one file. But i needs five files with todays date.

    Example :

    D:\Sample\20120606Sample1.txt

    D:\Sample\20120606Sample2.txt

    D:\Sample\20120606Sample3.txt

    D:\Sample\20120606Sample4.txt

    D:\Sample\20120606Sample5.txt

    Regards

    SqlStud

  • This was removed by the editor as SPAM

  • No Stewart.

    Only datepart given in the filename

  • Hi,

    You can append a random number to the file. This will create files with unique names.

    Select rand()

    Thanks

    ~Vishwanath

  • I have used the output file format in expression properties

    "\\"+ "\\Sample\\Shares\\Medical\\"+@V_Path+"\\MDM\\MDM_"+ (DT_WSTR,4)YEAR(GETDATE()) + RIGHT("0" + (DT_WSTR,2)MONTH(GETDATE()),2) + RIGHT("0" + (DT_WSTR,2)DAY(GETDATE()),2)+".csv"

    How will i use Random number? Please suggest

    Regards

    SqlStud

  • This was removed by the editor as SPAM

  • Ok..

    But the filename should append with numbers from 0-9

    ie

    Filename1.txt

    Filename2.txt etc

    Regards

    SqlStud

  • This was removed by the editor as SPAM

  • Not yet decided. but it will be at regular intervals

  • This was removed by the editor as SPAM

  • Thanks Stewart

    🙂

  • Hello - I had the same need and found this great link that solved it for me

    http://www.sqlnerd.com/ssis_dynamic_dates.htm

    good luck -

  • You could include system.io in the script task and get the fullname of the file .Then get the last number using the for each loop for file . Get the new file name and save it .

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply