Author |
Topic |
mikebird
Aged Yak Warrior
529 Posts |
Posted - 2008-04-21 : 05:56:36
|
I have a query running in QA. I really need to get output directly to a file. Is it possible?Right now I am copying the output string using ctrl-C and pasting to Notepad! When this script becomes a stored procedure I'll need a proper way to get output to a file. How do I do it?Thanks |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-21 : 06:51:30
|
You have three options in QA.1) Show the results as text2) Show the results as grid3) Export results as fileThey are all accesible with a toolbar button in QA. E 12°55'05.25"N 56°04'39.16" |
|
|
mikebird
Aged Yak Warrior
529 Posts |
Posted - 2008-04-21 : 07:03:40
|
Sure. Doing all this for years. But this is a point-and-click routine and I need a file popping out from a stored procedure in a directory I need it, as the script runsI now have the script in a stored procedure. Hoping to get the script generating the file before that, but I couldn't wait.The stored procedure is part of a job. The parameter'd HTML generated is PRINT'd and this created an error in the job, making the step and the whole job fail. The error message is actually the HTML output I wanted! But in a file!Now I'm SELECT'ing that to see what happens.Thanks... |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-21 : 07:39:49
|
Use BCP to create files.Or even DTS/SSIS. E 12°55'05.25"N 56°04'39.16" |
|
|
mikebird
Aged Yak Warrior
529 Posts |
Posted - 2008-04-21 : 08:06:31
|
When I looked at it last time, BCP seemed to be an OS program. DTS / SSIS parts of SQL Server, but still requiring human activity, with hand on mouse.I'm after automation in SQL script to create 100s of text files to be generated daily from the database, in the IN tray directory of a PDF converter for secure, readable files for an archive and to be sp_sendmail'd. Doesn't this kind of task get done every day?What good is a car if it can't go offroad sometimes? My database needs to make files without help. I miss UNIX. What has Microsoft done?!?!? |
|
|
mikebird
Aged Yak Warrior
529 Posts |
Posted - 2008-04-21 : 10:09:11
|
The answer to my questionisxp_cmdshell |
|
|
mikebird
Aged Yak Warrior
529 Posts |
Posted - 2008-04-23 : 11:15:02
|
A huge problem with using this was that Windoze command prompt (worst software borne of this Earth) will not accept < as a starting character, as it's thinking of file redirection... so goodbye HTML. No chance.I found a procedure I could recreate called sp_appendToFile. No matter its name, no need for how it was implemented, it takes parameters @filename and @text and I was astonished that none of you gurus had a clue how to create and write to a WinOS file from SQL Server. Unbelievable.Using sp_OACreate, sp_OAMethod |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-04-23 : 12:00:32
|
Yeah, we're a bunch of idiots here. I wouldn't bother asking anyone here for any more help, it would be a complete waste of your very valuable time.And you're absolutely right: all the problems you are experiencing are because of Micro$oft and Windoze. They are stupid.- Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2008-04-23 : 12:25:28
|
quote: Originally posted by mikebird DTS / SSIS parts of SQL Server, but still requiring human activity, with hand on mouse.
So schedule your DTS/SSIS package through SQL Job agent. Duh."Hand on mouse"...I can only imagine where the other hand is...e4 d5 xd5 Nf6 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 13:10:43
|
I find it very funny that his profile says SQL Server 2005 DBA and he couldn't initially figure out that you can call executables such as bcp from xp_cmdshell. That's SQL Server 2005 DBA 101.It's also very funny that he blames the products when it's his lack of knowledge that is the problem. The products provide everything that he needs. But they must be stupid since he isn't aware of them.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-23 : 13:45:46
|
Really mercy for the company he is working |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-04-23 : 14:13:54
|
quote: Originally posted by mikebird...I was astonished that none of you gurus had a clue how to create and write to a WinOS file from SQL Server. Unbelievable...
We're just a bunch of dummies here, and none of us have ever had to do anything so unusual and technically challenging as creating a file from the results of a query, because things like that can only be done in UNIX or LINUX.Certainly no one here has ever thought of using SQL Server Books Online or Google to find about one million references and examples of how to use BCP, DTS, Integration Services, or sp_makewebtask to do this. Or using SQL Server Reporting Services to create PDF files directly.CODO ERGO SUM |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-23 : 14:21:34
|
Stop now! Behave!Mikebird has gone through great pains from yesterday when working on jobs to this exhaustive task. E 12°55'05.25"N 56°04'39.16" |
|
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2008-04-23 : 14:25:51
|
quote: Originally posted by blindman
quote: Originally posted by mikebird DTS / SSIS parts of SQL Server, but still requiring human activity, with hand on mouse.
So schedule your DTS/SSIS package through SQL Job agent. Duh."Hand on mouse"...I can only imagine where the other hand is...e4 d5 xd5 Nf6
Do we even want to know??Terry |
|
|
|