SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


writing data from Table to Excel files in Loop based On a condition


writing data from Table to Excel files in Loop based On a condition

Author
Message
raj-377207
raj-377207
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 31
HI,

I am trying to load the data from table to Excel files.
I have 5 folders, each folder has an exel file called "Excel Upload.xlsx".

I need to write data into each of the excel file(into one of the sheet) based on one condition.

If the prefix of one of the ID in the table matches prefix of folder name then write that data back to that particular folder.
Ex: ID: "GARNIER SHAMPOO" then write back to \\servername\e$\Data\MDP_76_02\Inbound\Excel Upload\Garnier\excel upload.xlsx

I am facing issues while doing this, Can any one please provide me an approach.
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38954 Visits: 14411
Data Flow Task containing:

1. OLE DB Source that selects the data you need to export as a single resultset, i.e. a SELECT statement
2. Conditional Split that evaluates the ID column and creates 5 output streams based on the 5 folder prefixes you mentioned
3. Have an Excel Destination connected to each of the output streams that writes the data into the Excel sheets you mentioned.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
raj-377207
raj-377207
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 31
Thank you for the reply.
Since I am writing to 5 Different folders, I need to create 5 differnt Excel destination connections.
I would like to have a solution to get a foldername dynamically and match to prefix of the ID. I don't want to create multiple Excel connections. Can you please give a solution to achieve this.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search