devxlogo

Exporting Select Query to CSV File

Exporting Select Query to CSV File

Question:
Using the following SQL statement, I could export a select query into a dbf file at c: emp est.dbf

INSERT INTO test IN ‘C: emp’ ‘DBASE IV;’ SELECT * FROM Table1

How would I write a SQL statment to export the same select query to a CSV (comma separated) file?

Answer:
Transact SQL does not support importing or exporting from a file. However, SQL Server provides you several ways to do so. The BCP command, which is run from the command prompt, not ISQL, allows you to both import and export data from a table. The online help has a complete description of all the options.

See also  Does It Make Sense to Splurge on a Laptop?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist