【问题标题】:How to programatically save a query results to a text file?如何以编程方式将查询结果保存到文本文件?
【发布时间】:2009-06-24 09:59:41
【问题描述】:

SQL Server 2005 - 如何以编程方式将查询结果保存到文本文件? (即没有在分析器中选择结果到文件选项,而不是通过 sql 命令)?

例如

select * from northwind.dbo.suppliers

然后我将结果保存到 CSV 文件?

【问题讨论】:

    标签: sql-server sql-server-2005 tsql


    【解决方案1】:

    使用您选择的语言

    Open a SQL Connection
    Issue command (select)
    While not end_of_results
      for each column
        write column value
        write ','
      write new line
    Clean up connection
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多