c# - Data Flow Task with variable source -


in ssis package need put content of 2 sql queries in 2 sheets of excel file. results of 2 queries in 2 object variables, i'm wondering if can use data flow task this. issues :

  1. i don't know columns have (number of columns, names of columns), query created @ moment of execution set @qry = 'select ...' exec(@qry)
  2. i have same problem excel file, can't have precise template, know excel file we'll have 2 sheets. possible? if not, there way (script task, ssrs...)?

as general answer, no, can't ssis. since tagged c# however, can use ole add sheets excel file , add data sheets, http://jayadevjyothi.blogspot.com/2013/01/step-1-create-new-project.html . can done outside of ssis, or if solution needs run inside ssis, can put c# inside script task.

           // excel file path         string excelfilepath = @"f:\excel file.xlsx";         // connection string accessing excel file         string connectionstring = string.format(@"provider=microsoft.ace.oledb.12.0; data source={0}; extended properties=""excel 12.0 xml;hdr=yes""", excelfilepath);          using (oledbconnection connection = new oledbconnection(connectionstring))         {             try             {                 connection.open();                 using (oledbcommand command = new oledbcommand())                 {                     command.connection = connection;                     command.commandtext = "create table [students] ([first name] char(200), [last name] char(200), [age] char(2))";                     command.executenonquery();                     console.writeline("table created successfully");                 }                 console.readline();             }             catch (oledbexception ex)             {                 console.writeline("message: " + ex.message);                 console.readline();             }                         {                 connection.close();             }         } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -