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) --目標檔案
asdeclare @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
利用SQL行動硬碟檔案
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 移動伺服器上...
利用SQL行動硬碟檔案
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 移動伺服器上...
利用SQL行動硬碟檔案
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 移動伺服器上...