SQL Server query result to file

3.5k Views Asked by At

How can I save query result into file from sqsh console?

Google is talking about some gui tools I don't want to use.

PS: Linux

3

There are 3 best solutions below

1
njr101 On BEST ANSWER

I'm not familiar with sqsh but if it's a console tool, can you just pipe the output to a file?

sqsh <mycommand> >output.txt
1
marc_s On

Not familiar with that "sqsh" shell you're talking about.... but on Windows, you could use the command-line sqlcmd tool and execute a query against SQL Server, and capture the output into a file.

See:

0
Ocaso Protal On

From the SQSH homepage:

You may also redirect output to files and (if you are careful) can redirect input from files:

1> select * from sysobjects    
2> go 2>/dev/null >/tmp/objects.txt