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 2008 Forums
 SSIS and Import/Export (2008)
 Export data into CSV using query

Author  Topic 

Syamsul Izwani
Starting Member

1 Post

Posted - 2012-09-22 : 05:07:28
Hi,
How to export data from table into csv file just using query?
I want to download the data using CSV file did anyone know how to do this????

SYAMSUL

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-22 : 08:49:16
You can use bcp - there are examples on this MSDN page: http://msdn.microsoft.com/en-us/library/ms162802.aspx

BCP is a command that you run from a command line on the OS. To run it as a query, you will need to use xp_cmdshell: http://msdn.microsoft.com/en-us/library/ms175046.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-22 : 12:51:58
make sure xp_cmdshell is enabled in server before you use it. By default xp_cmdshell will be disabled and you've run sp_configure to enable it

see

http://blog.sqlauthority.com/2007/04/26/sql-server-enable-xp_cmdshell-using-sp_configure/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -