Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scottgriv/sql-mssql_excel_export
Export data from Microsoft SQL Server to Excel.
https://github.com/scottgriv/sql-mssql_excel_export
excel excel-export excel-exporter microsoft-sql-server microsoft-sql-server-management-studio microsoft-sqlserver-database mssql mssql-database mssql-server sql sql-database sql-server
Last synced: about 13 hours ago
JSON representation
Export data from Microsoft SQL Server to Excel.
- Host: GitHub
- URL: https://github.com/scottgriv/sql-mssql_excel_export
- Owner: scottgriv
- License: unlicense
- Created: 2023-04-20T02:25:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-09T04:27:34.000Z (30 days ago)
- Last Synced: 2025-02-06T07:41:23.423Z (2 days ago)
- Topics: excel, excel-export, excel-exporter, microsoft-sql-server, microsoft-sql-server-management-studio, microsoft-sqlserver-database, mssql, mssql-database, mssql-server, sql, sql-database, sql-server
- Language: TSQL
- Homepage:
- Size: 427 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
---------------
Export Microsoft SQL Server to Excel
Export data from a Microsoft SQL Server database to an Excel spreadsheet using this query.
---------------
## Table of Contents
- [Getting Started](#getting-started)
- [Resources](#resources)
- [License](#license)
- [Credits](#credits)## Getting Started
Run the query inside of the `excel_export.sql`, changing the following configuration options to your needs:
- xp_cmdshell is a system stored procedure in SQL Server. It allows executing Windows shell commands from the SQL Server environment. While commands are passed as an input string, the shell's output is returned as rows of text.
- Change -S to your DB server and -d to your Database, then change the query to what you want.
- If you want to hide the column headers, add the flag: -h-1 after the .csv" syntax. The only issue is that the dashes are tied to the column header.
- To remove the dashes but keep the header, do a UNION in your query with your column headers.
- 700 is the max width I set so you can adjust it if your columns are smaller/larger. This is for ALL columns.
- I’ve also remove the “Rows Affected” output from the bottom of the file by the “no_output” switch at the end of the command
- Adjust the -o flag to your desired output path and file name.## Resources
- [Microsoft SQL Server - 2022 Home](https://www.microsoft.com/en-us/sql-server/sql-server-2022)
- [Microsoft SQL Server - 2022 Documentation](https://learn.microsoft.com/en-us/sql/sql-server/?view=sql-server-ver16)
- [Microsoft SQL Server - Downloads](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)
- [Microsoft Excel](https://www.microsoft.com/en-us/microsoft-365/excel)## License
This project is released under the terms of **The Unlicense**, which allows you to use, modify, and distribute the code as you see fit.
- [The Unlicense](https://choosealicense.com/licenses/unlicense/) removes traditional copyright restrictions, giving you the freedom to use the code in any way you choose.
- For more details, see the [LICENSE](LICENSE) file in this repository.## Credits
**Author:** [Scott Grivner](https://github.com/scottgriv)
**Email:** [[email protected]](mailto:[email protected])
**Website:** [scottgrivner.dev](https://www.scottgrivner.dev)
**Reference:** [Main Branch](https://github.com/scottgriv/sql-mssql_excel_export)---------------