Export SQL Query To Excel

By Bernie FitzGerald •  Updated: 01/19/23 •  7 min read

There are many different databases where you can export data and then manage that data in an Excel spreadsheet. I have described the methods for several data sources to do this. Enjoy!

Export MSSQLServer Query To Excel

To export a SQL query to Excel, you can use a tool like Microsoft SQL Server Management Studio (SSMS) to run the query and export the results to an Excel spreadsheet. Here are the steps to do this in SSMS:

  1. Open SSMS and connect to the database where your query will be run.
  2. Write and execute your query in the query window.
  3. Once the query results are displayed, click the “Export” button on the toolbar or go to “File” > “Export” in the menu.
  4. In the “Export Data” window, select “Excel” as the format and choose a location to save the file.
  5. Click “OK” to export the query results to an Excel spreadsheet.

Alternatively, you can use the export option in excel to import the query results directly to excel.

Note that some steps may vary depending on the version of SSMS you are using and the type of data you are trying to export.

Export PostgreSQL Query To Excel

To export a PostgreSQL query to Excel, you can use a tool like pgAdmin to run the query and export the results to an Excel spreadsheet. Here are the steps to do this in pgAdmin:

  1. Open pgAdmin and connect to the database where your query will be run.
  2. Write and execute your query in the query window.
  3. Once the query results are displayed, right-click on the result set, choose ” Export ” option, and then select “Excel” as the format.
  4. Choose a location to save the file and click on the “Save” button.
  5. The query results will be exported to an Excel spreadsheet.

Alternatively, you can use the “COPY” command to copy the query results to a CSV file and then import that CSV file into Excel.

Note that some steps may vary depending on the version of pgAdmin you are using and the type of data you are trying to export.

Export MySQL Query To Excel

To export a MySQL query to Excel, you can use a tool like MySQL Workbench to run the query and export the results to an Excel spreadsheet. Here are the steps to do this in MySQL Workbench:

  1. Open MySQL Workbench and connect to the database where your query will be run.
  2. Write and execute your query in the query window.
  3. Once the query results are displayed, click the “Export to Excel” button on the toolbar or go to “Server” > “Data Export” in the menu.
  4. In the “Data Export” window, choose the options for the export, such as the location and format of the file.
  5. Click “Start Export” to export the query results to an Excel spreadsheet.

Alternatively, you can use the “INTO OUTFILE” clause in your SQL query to write the query results to a CSV file and then import that CSV file into Excel.

Note that some steps may vary depending on the version of MySQL Workbench and the type of data you are trying to export.

Export Oracle Query To Excel

To export an Oracle query to Excel, you can use a tool like Oracle SQL Developer to run the query and export the results to an Excel spreadsheet. Here are the steps to do this in Oracle SQL Developer:

  1. Open Oracle SQL Developer and connect to the database where your query will be run.
  2. Write and execute your query in the query window.
  3. Once the query results are displayed, go to “Tools” > “Export” in the menu.
  4. In the “Export” window, select “Excel” as the format and choose a location to save the file.
  5. Click “OK” to export the query results to an Excel spreadsheet.

Alternatively, you can use the “SPOOL” command in your SQL query to write the query results to a CSV file, and then import that CSV file into Excel.

Note that some steps may vary depending on the version of Oracle SQL Developer you are using and the type of data you are trying to export.

Export DynamoDb Query To Excel

DynamoDB is a NoSQL database service provided by Amazon Web Services (AWS), and it does not support natively exporting data to excel. However, you can use the following approach to export DynamoDB data to Excel:

  1. Use the AWS SDKs or the AWS CLI to query the data from DynamoDB and save the results to a CSV file.
  2. Open the CSV file in Excel, and use the “Data” > “From Text/CSV” feature to import the data into an Excel worksheet.

Here is an example of how you can use the AWS CLI to export data from a DynamoDB table to a CSV file:

aws dynamodb scan --table-name my-table --query "Items[*]" --output csv > my-table.csv

This command will scan all the items of the table “my-table” and output the results to a CSV file named “my-table.csv”

Alternatively, you can use an ETL tool like Glue or Data Pipeline to extract data from DynamoDB and load into a relational database like MySQL or PostgreSQL and then export it to excel.

Note that the steps may vary depending on the version of AWS SDKs or CLI and the type of data you are trying to export.

Export Mongo Query To Excel

MongoDB is a NoSQL database that does not support natively exporting data to excel. However, you can use the following approach to export MongoDB data to Excel:

  1. Use the MongoDB shell or a MongoDB driver to query the data from MongoDB and save the results to a CSV file.
  2. Open the CSV file in Excel, and use the “Data” > “From Text/CSV” feature to import the data into an Excel worksheet.

Here is an example of how you can use the MongoDB shell to export data from a MongoDB collection to a CSV file:

mongoexport --db=mydb --collection=mycollection --type=csv --fields=field1,field2,field3 --out=mycollection.csv

This command will export data from “mycollection” collection of “mydb” database and output the results to a CSV file named “mycollection.csv.”

Alternatively, you can use an ETL tool like Talend or Stitch to extract data from MongoDB and load into a relational database like MySQL or PostgreSQL and then export it to excel.

Note that the steps may vary depending on the version of the MongoDB shell or driver you are using and the type of data you are trying to export.

Export RavenDb Query To Excel

RavenDB is a NoSQL document database that does not support natively exporting data to excel. However, you can use the following approach to export RavenDB data to Excel:

  1. Use the RavenDB Studio or the RavenDB Client API to query the data from RavenDB and save the results to a CSV file.
  2. Open the CSV file in Excel, and use the “Data” > “From Text/CSV” feature to import the data into an Excel worksheet.

Here is an example of how you can use the RavenDB Studio to export data from a RavenDB collection to a CSV file:

  1. Open RavenDB Studio
  2. In the left navigation, Select the database and the collection.
  3. On the top right corner, use the “Export” button to export the data to CSV

Alternatively, you can use an ETL tool like Talend or Stitch to extract data from RavenDB and load into a relational database like MySQL or PostgreSQL and then export it to excel.

Note that the steps may vary depending on the version of RavenDB Studio or API you are using and the type of data you are trying to export.

Bernie FitzGerald