devxlogo

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.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Seasoned Architects Evaluate New Tech

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.