简体   繁体   中英

How to export SQL data in to excel

I am using SQLCMD command to run a script and i need to output the result in to an excel file in XLSX format. How do i do that ?

Thanks in advance.

I recommend you use the bcp utility to do that. The bcp utility works vary fast for situation like yours and it is very flexible. You can use it to output the contents of a table or query to a "comma separated file" using any column separator you want and then consume that file in Excel.

A also believe that you could name the file with the XLSX extension, but haven't tested that.

Here is the link to the utility's documentation.

If your script is more complex, I recommend you create a stored procedure for it's logic. You could drop this procedure once you're done with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM