I want to execute a Stored procedure in SQL Server 2008 and store the data in a text file. How to do this and how to generate a text file automatically with data in SQL Server 2008?
-
I would recommend checking out this link: thiagsundar.wordpress.com/export-data-to-text-file It shows a great way to export data to a text file from SQL Server.Andrew Backes– Andrew Backes2012-07-15 03:55:15 +00:00Commented Jul 15, 2012 at 3:55
-
Any language being used like c# ?user1499112– user14991122012-07-15 06:29:40 +00:00Commented Jul 15, 2012 at 6:29
Add a comment
|
1 Answer
One of the method is to make use of BCP (Bulk Copy Program) to do this. You need to have xp_cmdshell enabled to get this working.
Also you can also make use of SSIS Import/Export wizard to achieve this.
EXEC master..xp_cmdshell 'BCP "exec dbname.schemaname.procname" queryout "C:\outputfile.txt" -T -c -t,'
Check out these: