Use SQL mobile hard disk files

xiaoxiao2021-03-06  133

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

/ * - File on your mobile server

Do not use XP_cmdshell because this is disabled most of the time.

- Zou Jian 2004.08 (Please keep this information) - * /

/ * - Call example

EXEC P_MOVEFILE 'D: /AA.TXT', 'C: /' - * / CREATE PROC P_MOVEFILE @ S_File Varchar (1000), - Source File @d_file varchar (1000) - Target File asDeclare @err Int, @ SRC VARCHAR (255), @ desc varchar (255) Declare @obj Int

Exec @ err = sp_oacreate 'scripting.filesystemObject', @ Obj outif @err <> 0 goto lberr

Exec @ Err = SP_OAMETHOD @ Obj, 'Movefile', NULL, @ S_File, @ D_Fileif @err <> 0 goto lberr

Exec @ err = sp_oadestroy @objreturn

LBERR: EXEC SP_OAGETERRORINFO 0, @ src out, @DESC OUT SELECT CAST (@err as varbinary (4)) AS error number, @ src AS error source, @ DESC AS error Description Go

转载请注明原文地址:https://www.9cbs.com/read-127047.html

New Post(0)