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
 Import/Export (DTS) and Replication (2000)
 CREATE a CSV DATABASE FILE

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-10 : 19:27:47
Paul writes "IN SQL Script how do I create an empty csv file, and write to it?

Thanks in advance

Paul"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-02-10 : 20:00:08
The bcp command-line utility is actual the easiest way to create a CSV file. You can call it from T-SQL using xp_cmdshell:

EXEC xp_cmdshell 'bcp "SELECT * FROM pubs..authors" queryout c:\mydata.csv -Sserver -Uusername -Ppassword -c -t ","'

Check Books Online for more details on bcp.

Go to Top of Page
   

- Advertisement -