December 23, 2011 at 6:35 am
I have no idea regarding above this topic. But I need to export query result set to excel sheet through sql statement how to possible Plz give me an idea and a sample copy.
December 23, 2011 at 7:12 am
You can use BCP command with xp_cmdshell for your requirement
Please check the tutorial for a sample case at http://www.kodyaz.com/articles/sql-output-to-file-using-sql-server-bcp-command.aspx
Here is a sample
DECLARE @S nvarchar(4000)
SET @S = 'BCP "SELECT * FROM TableName" queryout "d:\file.xls" -c -UTF8 -T -Sservername'
EXECUTE master..xp_cmdshell @S
SQL Server and T-SQL Tutorials and Articles
Microsoft Certification and Certification Exams
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply