query to save in file | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

query to save in file

When I execute any select statement, output should be saved in a file specified
in a store procedure.How to write this type of store procedure.
Read about bcp in sql server help file
you can create procedure based on that code Madhivanan Failing to plan is Planning to fail
If not you can use OSQL or SQLCMD in this case using -o parameter,http://www.databasejournal.com/features/mssql/article.php/3491006 fyi. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.
plz show one example of store procedure. which store result of query in a specifird file. thnks..
SQL 2005 Books online is your best resource when using Search button.
http://www.sql-server-performance.com/sj_bol_april_2006.asp fyi. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.
Check BOL for complete syntax…
Here is the simple one…
osql -Sserver -Uuserid -Ppassword -ddbname -Q"exec procedurename" -o c:checkblk.out Note: -E for widows authentication… MohammedU.
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.

]]>