Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSIS Read Excel rows and create new output file

Status
Not open for further replies.

scottcabral1979

Programmer
Mar 16, 2012
30
US
Hi,

I have an excel file with following data:

Agent State Exposure Insured Name
Rogers Inc MA 100,000 John Smith
SAN Group RI 200,000 Jim Morrison
SAN Group RI 100,000 Jimi Hendrix
123 Agency MA 300,000 Mickey Mouse
Rogers Inc MA 50,000 Mike Greenwell

I want to be able to read the file and create new excel files for each Agent listed.

So for Example, the above file would create 3 separate files since there are 3 different Agents listed. Each Agent file would contain the same information from the original file. The name of the file would be somethign like AgentName.xls

So the SAN group file would have this:

Agent State Exposure Insured Name
Rogers Inc MA 100,000 John Smith
SAN Group RI 200,000 Jim Morrison
SAN Group RI 100,000 Jimi Hendrix

Is there a way to accomplish this in SSIS?

thanks
Scott
 
I would:

Read the file into a table in your database as is

Select distinct agents using SQL Query into a variable of type object (from your newly populated table)

Set up a for each loop using the object variable as the container (this will loop through the distinct list of agents

Assign an appropriate variable in the loop to hold your agent

Set up a DFT in the loop to:
select details from your newly populated table with a WHERE clause using your variable agent name to restrict the results
Use an excel destination object to output the results to a file - the connection can be made dynamic to pick up the agent name from teh variable you have populated

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
thanks Geoff,

This sounds logical to me. The trickiest part will be to dynamically have the excel file name change, but I should be able to find some examples of that online.

thanks
Scott
 
you should be quite easily able to create a variable destination

simply set the connectionstring property of the connection to an expression and have it pick up 1 or 2 variables from the package (base file path and agent name spring to mind)

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top