1

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

fl00r
  • 82,987
  • 33
  • 217
  • 237

3 Answers3

5

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
Ocaso Protal
  • 19,362
  • 8
  • 76
  • 83
4

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
njr101
  • 9,499
  • 7
  • 39
  • 56
2

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:

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459