您的位置:首页 > 数据库

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

2013-04-23 15:24 190 查看
首先需要开启xp_cmdshell

sp_configure 'show advanced options',1
reconfigure
go
sp_configure 'xp_cmdshell',1
reconfigure
go


然后再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




Declare @Path varchar(5000)
Set @Path='E:\Test.txt'
declare @Command varchar(5000)
set @Command='echo "'+@MyVarible+'">' + @Path
exec master..xp_cmdshell @Command
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: