February 11, 2005 at 7:02 am
I have a field with a datatype of image. I want to write this filed into a text file and this is the error I get
Server: Msg 206, Level 16, State 2, Line 17
Operand type clash: image is incompatible with nvarchar
Server: Msg 279, Level 16, State 1, Line 17
The text, ntext, and image data types are invalid in this subquery or aggregate expression.
Here is my code, to see how it works you can replace @cmd with 'Hello World' because the field I select (pcldata ) is an image, hence the error. Please help
Declare @FS int,
@ole int,
@file int,
@object int,
@filename varchar(100),
@cmd nvarchar(200),
@txt varchar(100)
set nocount on
set @filename = 'c:\Rob.pdf'
--set @cmd = 'erase c:\Rob.pdf'
EXECUTE @ole = sp_OACreate 'Scripting.FileSystemObject', @FS OUT
--select @FS
EXEC master..xp_cmdshell @cmd, NO_OUTPUT
set @cmd = (select a.pcldata from tblPclData a, tblBNLink b where a.id = b.PCLID and docType = 'BRKNOT' and a.id = 18181)
EXECUTE @ole = sp_OAMethod @FS, 'OpenTextFile', @file OUT, @filename, 8, 1
--select @file
EXECUTE @ole = sp_OAMethod @file, 'WriteLine', Null, @cmd
EXECUTE @ole = sp_OADestroy @file
EXECUTE @ole = sp_OADestroy @FS
GO
February 11, 2005 at 7:14 am
See if this helps:
http://www.microsoft.com/resources/documentation/sql/2000/all/reskit/en-us/part3/c1161.mspx
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply