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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Data to a file

Author  Topic 

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-04-02 : 10:33:28
Is there a command within SQL to send text (populated by variables) to a file?

What is the name of the command and the syntax?

Thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-02 : 10:38:58
Not clear what you mean. Can you provide an example?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-04-02 : 10:53:15
When I do anything in SQL script I usually get a grid of data in a window. I can also do

print 'rubbish'

in the window and I get that back in the Messages tab. What if I want to put the 'rubbish' string to a file in a directory? What if I want a grid of data to go a a file? Do I need to use an existing SP to do that? A system SP?
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-02 : 10:55:03
No. You can set Results to File option in Query Analyzer Tools, Options menu.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-04-02 : 11:04:23
OK

I'm not referring just to QA window. This is getting SQL Server to do things for me. It must be able to output results to places... anywhere... files!

If I set up my own SP to output 'rubbish' and put that into a file in the server, that must be possible! I need to create an HTML file, full of variables, deploying values, and put this into a file.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-02 : 11:09:26
You can use OSQL utility to output results to file.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-04-02 : 11:09:57
What is OSQL?
Go to Top of Page

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-04-02 : 11:12:10
when I run the .exe I am asked



Password:
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-02 : 11:12:23
You will find all the information about OSQL utility in SQL Server help.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -