devxlogo

SQL Redirection to a Text File

SQL Redirection to a Text File

Question:
How do I redirect the output of a SQL query to a file?

Answer:
Use the isql command-line switches to redirect the output of a query to a file. Try this line, substituting your server name after the /S:

 D:>isql /q EXIT("SELECT * FROM pubs.dbo.authors") /SYourServerName /U"SA" /P"" > MYTEXT.TXT

The redirection symbol (>) moves it to the text file.

devx-admin

Share the Post: