SQL Server- How to write variables and query results to Text file?(SQL Server - 如何将变量和查询结果写入文本文件?)
问题描述
如何使用 T-SQL、变量值和查询结果写入文本文件,我想实际继续追加.
How do I write using T-SQL, variable values and query results to a text file, I want to actually keep appending.
推荐答案
您可以使用 SQL CLR 将您想要的任何内容写入文件.您可以自己编写代码,也可以使用 SQL# 库(我是作者,它不是免费的——对于这个函数——但也不贵)并使用 File_WriteFile 函数写出文本.它允许附加数据.该库对于大多数函数是免费的,但对于文件系统函数则不是.可以在以下位置找到:http://www.SQLsharp.com/
You can use SQL CLR to write whatever you want out to a file. You can either code this yourself or you can use the SQL# library (I am the author and it is not free -- for this function -- but not expensive either) and use the File_WriteFile function to write out the text. It allows for appending data. The library is free for most functions but not for the File System functions. It can be found at: http://www.SQLsharp.com/
如果你想尝试自己编码,我发现这个例子是我认为你要求的基本概念:http://www.mssqltips.com/tip.asp?tip=1662
If you want to try coding this yourself, I found this example which is the basic concept I think you are asking for: http://www.mssqltips.com/tip.asp?tip=1662
这篇关于SQL Server - 如何将变量和查询结果写入文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server - 如何将变量和查询结果写入文本文件
基础教程推荐
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 无法解决整理冲突 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
