如何使用sql脚本创建和写入文本文件 [英] How to create and Write into Text file using sql Script
本文介绍了如何使用sql脚本创建和写入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用sql创建并写入文本文件.
我写了以下代码:
I want to create and Write into text file using sql.
I had written following code:
Declare @Path varchar(5000)
Set @Path='D:\Data\Test.txt'
declare @Command varchar(5000)
set @Command='echo "Hello World">' + @Path
exec master..xp_cmdshell @Command
但是我收到错误消息,因为系统找不到指定的路径."
已添加代码标签-LOSMAC [/EDIT]
But i am getting an error as "The system cannot find the path specified."
Code tags added - LOSMAC[/EDIT]
推荐答案
^ ]
参考: http ://www.simple-talk.com/sql/t-sql-programming/reading-and-writing-files-in-sql-server-using-t-sql/ [
http://www.simple-talk.com/code/WorkingWithFiles/spWriteStringTofile.txt[^]
Ref:http://www.simple-talk.com/sql/t-sql-programming/reading-and-writing-files-in-sql-server-using-t-sql/[^]
这篇关于如何使用sql脚本创建和写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文