Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sarahmfr
Posting Yak Master
214 Posts |
Posted - 2011-11-17 : 00:01:01
|
How to run an excel macro through ssisIf I have an excel spreadsheet book1.xlsI want to split it to various sheetscolumn1 column2 in sheet1column1 column3 in sheet2column1 column4 in sheet 3etc.Is there a way to do it in ssis having xls as a source and outpupt exel as a destinationsarah |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-17 : 01:00:53
|
you dont have to use macro for splitting. you can do it while generating excel inside ssis itself------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
sarahmfr
Posting Yak Master
214 Posts |
Posted - 2011-11-18 : 00:46:17
|
How can I do that?----------------Is there a way to know how many columns with data exist in an excel spreadsheet?i.e.If I have an excel spreadsheet first column is student number and the following columns are quizzesthe number and name of quizzes can vary from one section to another.Thankssarah |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-18 : 03:13:18
|
quote: Originally posted by sarahmfr How can I do that?----------------Is there a way to know how many columns with data exist in an excel spreadsheet?i.e.If I have an excel spreadsheet first column is student number and the following columns are quizzesthe number and name of quizzes can vary from one section to another.Thankssarah
do you mean your excel columns are not static?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
sarahmfr
Posting Yak Master
214 Posts |
Posted - 2011-11-18 : 18:06:24
|
yesin other words what i am trying to achieve isi have an excel spreadsheet that has studentid, and a list of columns each represents the student's grade in a quizeach section provide us with such a sheet and every section has different number and names of quizzesi would like to use ssis to import from those excel sheets to a table studentid quizname sectionid scoreI tried to use unpivoting in ssis and then import the result to a table but the issue with pivoting that it depends on the column names and number appreciate your helpsarah |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-19 : 02:11:24
|
i think in your scenario it might be best to pull the rows from excel to a table by using OPENROWSET and then apply dynamic UNPIVOT to get the columns onto rows and then getting it onto your table. so ssis package will look likeExecute SQL Task -> check if intermediate tables (unpivotted and other) exists and if yes drop itExecute SQL Task-> SELECT * INTO intermediatetable FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=excelpathhere', [Sheetname$])if you want you can pass excel path and sheetname values through variables in which case you need to use sql source type as variableAdd a string variable to package to store the column list of intermediate table and use query on INFORMATION_SCHEMA.COLUMNS to populate it with all column names except studentidExecute SQL Task-> unpivot query based on column list generated in above variable. you can use sourcetype as variable and create another variable to hold query with column list appended using already created column list variable and put it in new unpivotted intermediate tableData flow task-> simple one to one transfer from unpivotted intermediate table to your final table------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
sarahmfr
Posting Yak Master
214 Posts |
Posted - 2011-11-20 : 14:11:52
|
Thanks so much.You are the best. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-20 : 23:39:54
|
wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|