以下代码将图像保存到本地文件夹时有效,但是当我包含要保存到远程文件夹的服务器IP时失败
DECLARE @ImageData VARBINARY(MAX),
@UserId NVARCHAR(200),
@Path NVARCHAR(1024),
@Filename NVARCHAR(1024),
@ObjectToken INT;
SELECT @Path = 'C:\Images\Profile\Approved';
DECLARE @FullPathToOutputFile NVARCHAR(2048);
SELECT @FullPathToOutputFile = '\\<ServerIP>\'+@Path + '\' + 'abc.jpg';
EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT;
EXEC sp_OASetProperty @ObjectToken, 'Type', 1;
EXEC sp_OAMethod @ObjectToken, 'Open';
EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @ImageData;
EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @FullPathToOutputFile, 2;
EXEC sp_OAMethod @ObjectToken, 'Close';
EXEC sp_OADestroy @ObjectToken;