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 Administration (2000)
 SQL QUERY

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-02-14 : 08:29:09
farai writes "How do I save the output of an sql query to a file (and give it a name) in command i.e without using the save output to file(execute mode) graphical user interface, I also want to send the created file by email as an attachment."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-14 : 08:32:31
Use bcp

Exec Master..xp_Cmdshell 'bcp "Select columns from DBName..TableName" queryout "C:\results.txt" -c'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -