none
how to bulk insert a table to csv file

    Question

  • how to bulk insert a stored procedure to csv file.. from inside isql to produce a csv file
    • Moved by Gert Drapers Saturday, July 20, 2013 4:47 PM Tsql question not a tools one
    Saturday, July 20, 2013 3:36 PM

Answers

  • Hi abe_icm,

    We can use the following commands to create a stored procedure which can output data to a CSV file.

    create proc TestOut 
    as 
    exec xp_cmdshell 'bcp AdventureWorks2008R2.Sales.Currency out D:\data\Currency.csv -T -c'  
    
    -- To execute stored procedure TestOut
    exec TestOut
    
    For more detail information, you can refer to the following link:

    xp_cmdshell (Transact-SQL)
    http://msdn.microsoft.com/en-us/library/ms175046.aspx

    bcp Utility
    http://msdn.microsoft.com/en-us/library/ms162802.aspx


    Allen Li
    TechNet Community Support

    Tuesday, July 23, 2013 2:23 AM

All replies