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


Export multiple files to Excel using SSIS


Export multiple files to Excel using SSIS

Author
Message
SceloM
SceloM
Old Hand
Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)

Group: General Forum Members
Points: 361 Visits: 190
Hi all

Can someone please help me with a link that has an example on how to export data to multiple Excel files.
Files will be created for different department.

I have looked at the example obtained here http://www.devtechie.com/post/2012/02/29/Export-Data-into-multiple-Excel-file-SSIS.aspx but I get an error about the DepartmentReport table already existing, tried to add a File System Task but I am still struggling.

Will appreciate any assistance.
SceloM
SceloM
Old Hand
Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)

Group: General Forum Members
Points: 361 Visits: 190
In case someone may need this in future.
I found a solution to my problem from this site https://www.simple-talk.com/sql/ssis/implementing-foreach-looping-logic-in-ssis-/.
A great article in there and I created a package based on it and it worked.
Just one thing though, when creating the JobTitle variable do not put the double quotes in the Value field, just leave the Value field blank.
Debbie Edwards
Debbie Edwards
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2086 Visits: 696
Excellent piece and its helped me figure out my problem with adding the files to a folder.

My problem is that my folders arent on the C drive but they are in a specific folder.... e.g.

And when I add this to the connection string like it says in the documentation

"C:\\DataFiles\\" + @[User::JobTitle] + ".csv"

But this instead.....

\\D-fs11\example-it\PROJECTS\DATA WAREHOUSING\Extract_To_CSV+@[User::CODE_NAME_DATE_File_Name]+".csv"

I get an error message

Attempt to parse the expression failed. The toke "\" at line number 0 was not recognised. Im beginning to think that you have to add all the folders for this to the C Drive only.
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)

Group: General Forum Members
Points: 51330 Visits: 21156
Debbie Edwards (2/21/2013)
Excellent piece and its helped me figure out my problem with adding the files to a folder.

My problem is that my folders arent on the C drive but they are in a specific folder.... e.g.

And when I add this to the connection string like it says in the documentation

"C:\\DataFiles\\" + @[User::JobTitle] + ".csv"

But this instead.....

\\D-fs11\example-it\PROJECTS\DATA WAREHOUSING\Extract_To_CSV+@[User::CODE_NAME_DATE_File_Name]+".csv"

I get an error message

Attempt to parse the expression failed. The toke "\" at line number 0 was not recognised. Im beginning to think that you have to add all the folders for this to the C Drive only.


I don't think so. Could it be that single backslash characters are causing an issue? (You may need to double them up.)


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.
SceloM
SceloM
Old Hand
Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)

Group: General Forum Members
Points: 361 Visits: 190
Debbie Edwards (2/21/2013)
Excellent piece and its helped me figure out my problem with adding the files to a folder.

My problem is that my folders arent on the C drive but they are in a specific folder.... e.g.

And when I add this to the connection string like it says in the documentation

"C:\\DataFiles\\" + @[User::JobTitle] + ".csv"

But this instead.....

\\D-fs11\example-it\PROJECTS\DATA WAREHOUSING\Extract_To_CSV+@[User::CODE_NAME_DATE_File_Name]+".csv"

I get an error message

Attempt to parse the expression failed. The toke "\" at line number 0 was not recognised. Im beginning to think that you have to add all the folders for this to the C Drive only.


Try "\\D-fs11\\example-it\\PROJECTS\\DATA WAREHOUSING\\Extract_To_CSV\\" +@[User::CODE_NAME_DATE_File_Name]+".csv"
Debbie Edwards
Debbie Edwards
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2086 Visits: 696
Ive had an better error message telling me the example same thing so at least thats something to go on!

Still I tried doubling up \\\\ and got the same error message.

Hmmmmm. Such a tiny part of it. So annoying when these things take up so much time
Debbie Edwards
Debbie Edwards
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2086 Visits: 696
Just realised I have been an idiot on this one!

I blame my smaller screen and terrible eyesight Blush

Of course thats what was meant!

Thank you
SceloM
SceloM
Old Hand
Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)

Group: General Forum Members
Points: 361 Visits: 190
Debbie Edwards (2/21/2013)
Just realised I have been an idiot on this one!

I blame my smaller screen and terrible eyesight Blush

Of course thats what was meant!

Thank you


So all sorted now?
Debbie Edwards
Debbie Edwards
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2086 Visits: 696
Not yet...

I have another error message about

The token [The symbol for square] at line number zero
....

Im imagining this is because I have spaces in the folder names that I will need to replace with another symbol. This is just a guess though.

Difficult to find documentation about this stuff
Debbie Edwards
Debbie Edwards
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2086 Visits: 696
Ive been a bit daft again. I already have a variable with the folder in.

Ive concatenated this and the file name together to get the whole shebang.

@[Extract_To_CSV_Folder]+@[User:BigGrinFES_NAME_DATE_File_Name]+".csv"Hopefully this will work.

Fingers crossed
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