首页 > 数据库技术 > 详细

在SQL脚本中进行文件的读写

时间:2015-02-12 18:10:39      阅读:238      评论:0      收藏:0      [点我收藏+]
  在SQL脚本中进行文件的读写
 
  首先需要开启xp_cmdshell
[sql] 
sp_configure ‘show advanced options‘,1  
reconfigure  
go  
sp_configure ‘xp_cmdshell‘,1  
reconfigure  
go  

  然后再SQL中插入:

[sql] 
Declare @Path varchar(5000)  
Set @Path=‘E:\Test.txt‘   
declare @Command varchar(5000)  
set @Command=‘echo "Hello World Rex">‘ + @Path  
exec master..xp_cmdshell @Command  
 
或
[sql] 
Declare @Path varchar(5000)  
Set @Path=‘E:\Test.txt‘   
declare @Command varchar(5000)  
set @Command=‘echo "‘+@<strong>MyVarible</strong>+‘">‘ + @Path  
exec master..xp_cmdshell @Command  

  

文章来源:在SQL脚本中进行文件的读写

在SQL脚本中进行文件的读写

原文:http://www.cnblogs.com/qxoffice2008/p/4288558.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!