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


ssis for each loop into files help


ssis for each loop into files help

Author
Message
SQL_Kills
SQL_Kills
SSC Veteran
SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)

Group: General Forum Members
Points: 249 Visits: 804
Hi,

I have the following table



CREATE TABLE [dbo].[Orders](
[orderNo] [varchar](10) NOT NULL,
[orderLineNo] [int] NOT NULL,
[product] [varchar](10) NULL,
[orderQty] [int] NULL,
[receivedQty] [int] NULL,
[orderStatus] [varchar](10) NULL
) ON [PRIMARY]

insert into values Orders values ('A1000',1,'ABC100',10,10)
insert into values Orders values ('A1000',2,'ABC100',15,15)
insert into values Orders values ('A1000',3,'ABC101',17,17)
insert into values Orders values ('A1001',1,'ABC101',5,4)
insert into values Orders values ('A1001',7,'ABC103',50,1)
insert into values Orders values ('A1001',8,'ABC104',25,25)
insert into values Orders values ('A1002',1,'ABC104',24,23)
insert into values Orders values ('A1002',2,'ABC100',15,15)
insert into values Orders values ('A1003',1,'ABC105',50,0)





For each OrderNo I want to create a Text File into my C: Drive Folder, so the file name will look something like this "C:\A1000.txt" with each text file having the result for each of the OrderNo's it loops through.

Thanks
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18199 Visits: 20392
For each OrderNo I want to create a Text File into my C: Drive Folder, so the file name will look something like this "C:\A1000.txt" with each text file having the result for each of the OrderNo's it loops through.


OK. Now please state your question.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
SQL_Kills
SQL_Kills
SSC Veteran
SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)

Group: General Forum Members
Points: 249 Visits: 804
1. I need to create a ssis package
2. I want it to query the orders table for each orderid then for each result set it returns for each orderid to create a text file.
3. Each text file I would like the name of the orderid it has queried.
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18199 Visits: 20392
SQL_Kills (12/16/2013)
1. I need to create a ssis package
2. I want it to query the orders table for each orderid then for each result set it returns for each orderid to create a text file.
3. Each text file I would like the name of the orderid it has queried.


I understand your requirement, but you have not told us which part you need help with. At the moment, I am therefore suspecting the following:

"Please write this entire package for me, for free, so that I can take all the credit and pretend that I know what I am doing."

--Edit: fix typo


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
SQL_Kills
SQL_Kills
SSC Veteran
SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)

Group: General Forum Members
Points: 249 Visits: 804
Just advice on how to do this?

Would I need to first select a distinct list of Orderid's then pass this to the foreach loop container?

Not sure then how it would know which id it is going to use then when creating the file and if the results in the file relates to the same text file?
SQL_Kills
SQL_Kills
SSC Veteran
SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)SSC Veteran (249 reputation)

Group: General Forum Members
Points: 249 Visits: 804
I've worked it out now, so I don't need help on how to do this.
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18199 Visits: 20392
SQL_Kills (12/16/2013)
I've worked it out now, so I don't need help on how to do this.


Well done. I have some ideas about how I would do it and will post back later if I have time - maybe it will be of interest to you.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
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