简体   繁体   English

从SQL查询导出到Excel

[英]export to excel from sql query

I am trying to export to excel from the following query. 我正在尝试从以下查询导出到excel。 The following query doesn't work. 以下查询不起作用。 Please let me know. 请告诉我。 I appreciate any help. 感谢您的帮助。

   INSERT INTO OPENROWSET ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=c:\test.xls;','
    select distinct a.a_name, b.b_name, 
    CASE WHEN a.rights  = 1 THEN 'Yes' ELSE 'No' END AS rights 
    FROM TABLE_A a 
    JOIN TABLE_B b ON a.a_id = b.a_id')

You can use Export Import Wizard in SSMS. 您可以在SSMS中使用“导出导入向导”。

  1. Right-click on the database which your query is using 右键单击查询所使用的数据库
  2. Choose TASKS from the context menu which opens after right-clicking 从右键单击后打开的上下文菜单中选择“任务”
  3. Choose EXPORT DATA from menu 从菜单中选择导出数据
  4. SQL Server Import and Export window will open. SQL Server导入和导出窗口将打开。
  5. In the wizard select your data source and where to export the data. 在向导中,选择数据源以及将数据导出到的位置。
  6. Enjoy! 请享用!

Additional info/ tutorial can be found here Please check http://www.kodyaz.com/articles/sql-server-export-to-excel-using-import-export-wizard.aspx 可以在此处找到其他信息/教程,请检查http://www.kodyaz.com/articles/sql-server-export-to-excel-using-import-export-wizard.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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