数据库

本类阅读TOP10

·SQL语句导入导出大全
·SQL Server日期计算
·SQL语句导入导出大全
·SQL to Excel 的应用
·Oracle中password file的作用及说明
·MS SQLServer OLEDB分布式事务无法启动的一般解决方案
·sqlserver2000数据库置疑的解决方法
·一个比较实用的大数据量分页存储过程
·如何在正运行 SQL Server 7.0 的服务器之间传输登录和密码
·SQL中两台服务器间使用连接服务器

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
利用SQL移动硬盘文件

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_movefile]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_movefile]
GO

/*--移动服务器上的文件

 不借助 xp_cmdshell ,因为这个在大多数时候都被禁用了

--邹建 2004.08(引用请保留此信息)--*/

/*--调用示例

 exec p_movefile 'd:\aa.txt','c:\'
--*/
create proc p_movefile
@s_file varchar(1000), --源文件
@d_file varchar(1000) --目标文件
as
declare @err int,@src varchar(255),@desc varchar(255)
declare @obj int

exec @err=sp_oacreate 'Scripting.FileSystemObject',@obj out
if @err<>0 goto lberr

exec @err=sp_oamethod @obj,'MoveFile',null,@s_file,@d_file
if @err<>0 goto lberr

exec @err=sp_oadestroy @obj
return

lberr:
 exec sp_oageterrorinfo 0,@src out,@desc out
 select cast(@err as varbinary(4)) as 错误号
  ,@src as 错误源,@desc as 错误描述
go




相关文章

相关软件