zoukankan      html  css  js  c++  java
  • 利用SQL移动硬盘文件(转于zjcxc)

    导读:

     1 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_movefile]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
    2   drop procedure [dbo].[p_movefile]
    3   GO
    4   /*--移动服务器上的文件
    5   不借助 xp_cmdshell ,因为这个在大多数时候都被禁用了
    6   --邹建 2004.08(引用请保留此信息)--*/
    7   /*--调用示例
    8   exec p_movefile 'd:/aa.txt','c:/'
    9   --*/
    10   create proc p_movefile
    11   @s_file varchar(1000), --源文件
    12   @d_file varchar(1000) --目标文件
    13   as
    14   declare @err int,@src varchar(255),@desc varchar(255)
    15   declare @obj int
    16   exec @err=sp_oacreate 'Scripting.FileSystemObject',@obj out
    17   if @err<>0 goto lberr
    18   exec @err=sp_oamethod @obj,'MoveFile',null,@s_file,@d_file
    19   if @err<>0 goto lberr
    20   exec @err=sp_oadestroy @obj
    21   return
    22   lberr:
    23   exec sp_oageterrorinfo 0,@src out,@desc out
    24   select cast(@err as varbinary(4)) as 错误号
    25   ,@src as 错误源,@desc as 错误描述
    26   go



  • 相关阅读:
    Mac OS 下包管理器 homebrew的安装
    草根程序员八年百万年薪之路
    div隐藏滚动条,仍可滚动
    感觉身体被掏空by彩虹室内合唱团
    添加bash命令
    mysql性能优化
    PHP变量存储结构
    轻量级MVC框架(自行开发)
    一致性hash算法之php实现
    redis安装
  • 原文地址:https://www.cnblogs.com/ayan/p/2311492.html
Copyright © 2011-2022 走看看