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

来源:互联网 发布:js 掷骰子动画 编辑:程序博客网 时间:2024/04/29 07:05

首先需要开启xp_cmdshell

sp_configure 'show advanced options',1reconfiguregosp_configure 'xp_cmdshell',1reconfigurego

然后再SQL中插入:

Declare @Path varchar(5000)Set @Path='E:\Test.txt' declare @Command varchar(5000)set @Command='echo "Hello World Rex">' + @Pathexec master..xp_cmdshell @Command

Declare @Path varchar(5000)Set @Path='E:\Test.txt' declare @Command varchar(5000)set @Command='echo "'+@MyVarible+'">' + @Pathexec master..xp_cmdshell @Command


原创粉丝点击