Ask a questionAsk a question
 

Answerssis

  • Tuesday, November 03, 2009 9:28 PMrahul_saxena Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    i want to take a excel file (everyday diff)from my folder and
    send that file to my email using send mail task using ssis and dumps data to sql table.
    and in that  file, the data and name  keeps changing everyday..so i dont know how to create a varible in connection string that keep changing excel connection manager..

Answers

  • Wednesday, November 04, 2009 1:43 AMNitesh Rai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Just to add on what Mohan has suggested:
    Take a variable (sheetname) inside SSIS package and give the name of excel sheet as its value (Sample.xls).
    Then configure the data flow task as required, using dataaccessmode as table/view name from variable in excel source.
    Then select the variable sheetname.

    Go to expressions properties of the excel connection manager and write an expression for its connectionstring:

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + "C:\\MyFile\\" + @[User::sheetname] + "
    ;Extended Properties="  +"\"EXCEL 8.0;HDR=YES;;"  + "\";"

    Above conection string is to read the file from C:\MyFile\Sample.xls.

    Now use Mohans suggestion to change the value of excel file name using Package Configuration.


    Nitesh Rai- Please mark the post as answered if it answers your question

All Replies

  • Tuesday, November 03, 2009 10:23 PMMohan Kumar - SQLVillage.com Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    There are multiple way to achieve this but one way is to :

    1. enable "Package Configuration", select configuration type SQL Server provide table name that will keep all configuration information.
    2. Update ConfiguredValue column before executing SSIS
    3. Run SSIS

  • Wednesday, November 04, 2009 1:43 AMNitesh Rai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Just to add on what Mohan has suggested:
    Take a variable (sheetname) inside SSIS package and give the name of excel sheet as its value (Sample.xls).
    Then configure the data flow task as required, using dataaccessmode as table/view name from variable in excel source.
    Then select the variable sheetname.

    Go to expressions properties of the excel connection manager and write an expression for its connectionstring:

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + "C:\\MyFile\\" + @[User::sheetname] + "
    ;Extended Properties="  +"\"EXCEL 8.0;HDR=YES;;"  + "\";"

    Above conection string is to read the file from C:\MyFile\Sample.xls.

    Now use Mohans suggestion to change the value of excel file name using Package Configuration.


    Nitesh Rai- Please mark the post as answered if it answers your question