Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2015-02-05 : 10:22:59
|
Hi, I have a reporting model made in excel. A user enters all parameters in excel and the SQL code is generated for it. Next a macro is run that copies the data and it is pasted into a new query window in SQL management studio. Next, I would like to take the results and store them in a directory as a csv or excel file, the directory varies and will be specified by the user. Can this be done? If so, how??Thank you! |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-02-05 : 10:50:58
|
What I would do is:1. Save the generated query to disk instead of opening it in SSMS.2. Write a SSIS package that reads the query into a new column in the dataflow3. Add a script transformation that takes the column holding the query and assigns it to a variable4. Add a second data flow5. In the second dataflow, use an OLEDB source transformation that runs the query from step 36. Add a flat-file destination to take the results of step 3 and write them to disk |
|
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2015-02-05 : 13:51:30
|
I don't know anything about SSIS, can you tell me where to start? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2015-02-05 : 15:16:33
|
Have the macro execute the code against SQL Server, open a textfile and iterate and output all rows with the macro.Simple as that. Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2015-02-06 : 06:30:58
|
I just dont know how to do that but I will figure it out, doesn't sound too simple though.....Thanks!! |
|
|
qroonqroon
Starting Member
3 Posts |
Posted - 2015-03-12 : 21:03:26
|
In my opinion, the author's idea is advisable.I will make advertisement freely for your post,recommend it to my frields.But you can also click here for read.http://www.rsgpfast.com/ |
|
|
|
|
|
|
|