Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip rows: Export data from SSIS into excel file

I am trying to export data from a SQL server database into an excel file using SSIS. I want the data to get inserted from the 6th row and 5th row has headers.

enter image description here

I am able map the header names, in Excel Destination Editor, to the SQL table headers, by writing the SQL command:

SELECT * FROM [Sheet1$A5:EC5]

But still, when I execute the package, the data gets inserted from the 2nd row How can I start the insertion from 6th row?

Any help, to solve this, is appreciated. Thanks in advance!

like image 284
SMS Avatar asked Mar 13 '17 21:03

SMS


People also ask

How do I prevent blank rows in SSIS destination in Excel?

I resolved the issue by selecting the whole spreadsheet except for the title row and by deleting the selection (right-clik and choose delete). This must have removed any left-behind formatting of blank cells. Then I put my selection to cell A1, saved the empty xlsx file and now SSIS starts writing the output on line 2.

How you can skip initial 200 rows while uploading a flat file in SSIS?

For SSIS, in the Flat File Connection Manager, you have an option that mentions Header rows to skip. On that option, you need to set it to 2 and check the Column names in the first row checkbox. That should handle the file if the row delimiters are consistent.


2 Answers

You need to use "OpenRowset" properties for excel source, go to the properties page for excel source, set the "OpenRowSet" as "$A6:D", then it should solve your problem.

like image 192
LONG Avatar answered Oct 06 '22 01:10

LONG


Add the blank rows to the dataset in OLE DB source in SSIS. I assume that your columns in your database are named Header1, Header2 and Header3. Replace your OLE DB source query with this query:

 select ' ' as Header1, ' ' as Header2, ' ' as Header3
 UNION ALL
 select ' ', ' ', ' '
 UNION ALL
 select ' ', ' ', ' '
 UNION ALL
 select ' ', ' ', ' '
 UNION ALL
 select ' ', ' ', ' '
 select Header1, Header2, Header3 from Your_SQL_SERVER_Tabl

You may need to cast your columns to varchar if they are of other types.

like image 20
TheEsnSiavashi Avatar answered Oct 06 '22 00:10

TheEsnSiavashi