I am using a cursor to write out images stored in a database to text.
Code snippet here:
DECLARE @SOURCEPATH VARBINARY(MAX),
@DESTPATH VARCHAR(MAX),
@ext varchar(MAX),
@ObjectToken INT,
@image_ID Varchar(255)
DECLARE IMGPATH CURSOR FAST_FORWARD FOR
SELECT <my data>
FROM <my table>
OPEN IMGPATH
FETCH NEXT FROM IMGPATH INTO @SOURCEPATH, @image_ID
WHILE @@FETCH_STATUS = 0
BEGIN
SET @DESTPATH = '<my path>'+ @image_ID
EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT
EXEC sp_OASetProperty @ObjectToken, 'Type', 1
EXEC sp_OAMethod @ObjectToken, 'Open'
EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @SOURCEPATH
EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @DESTPATH, 2
EXEC sp_OAMethod @ObjectToken, 'Close'
EXEC sp_OADestroy @ObjectToken
FETCH NEXT FROM IMGPATH INTO @SOURCEPATH, @image_ID
END
CLOSE IMGPATH
DEALLOCATE IMGPATH
I am able to write to a local drive without a problem, but I cannot write to the network share that I'd like to write to. I've followed the steps here,
in an effort to make the drive "visible" to SQL Server, but I still am not having any luck writing the images to this mapped drive.
Is this functionality supported, should I go down the route of checking permissions with our network guys, or is this not something that is possible?