How would I output to a text file to the user’s hard drive from SQL Server 2008? In the scenario the user’s hard drive is the same hard drive containing the SQL Server.
I don’t want the output to be a .csv file or an xml file, just plain text. I also need to do this in the code. I don’t want the user to have to manually click export or another GUI button everytime. My plan is to include this functionality in a stored procedure.
You forgot to mention which version of SQL Server you’re using, but assuming SQL Server 2005 or better, I would use SQLCLR for this, not xp_cmdshell or sp_OACreate. See the earliest answer to this question.