I am needing to get the data out of a table that has an image datatype, and create an insert statement so that the data can be inserted into other databases(to be used as part of an upgrade script).
I have used the procedure InsertGenerator in the past to create insert statements out of tables that have data. This is the first time I have come across the image datatype. The image part of the procedure looks like this: (@.dataType, @.colName, and @.stringData are nvarchar)
IF @.dataType='image'
BEGIN
SET @.stringData=@.stringData+'''''''''+
isnull(cast(convert(varbinary,'+@.colName+')
as varchar(6)),''0'')+'''''',''+'
END
It successfully creates the insert statement. The insert statement runs successfully, but I am not sure if the image itself is ok. When I use the related application, it crashes and I cannot tell if it is because of the image. When I run a sql trace the last statement ran is pulling back the image as well as a few other columns. When I run the trace statement in query analyzer, it works, but in query analyzer it isnt displaying the image.
My question is will the above statement successfully convert an image to a value that can be inserted into another table and the image recreated when you run the application? Is there something else I need to do to get the image value in a table out so that it can be used in an insert statment.
BTW this is on SQL 2000.
Thank you so much,
Tracey
This thread (found by just looking down the message list without having to even change pages -WOW), may give you the information you desire.
Using a stored procedure to reinsert an image
|||
Perhaps I am not understanding, I am using a script to create and insert statement an example is below. The FileBinary column is the image. I cannot tell if this is correctly extracted as am image. The insert is successful when ran in query analyzer, but the image doesnt display in the application, the application crashes, so I cant tell if it is the image or not.
Creating an insert statement to the same database is not what Im trying to do. I am trying to create an insert statement that can be ran on other like databases not on the network, that are needing this piece of information for the latest version of our application.
insert into JTFile (FileID, Path, Name, Extension, Type, Description, HashValue, Seed, RecordActive,FileBinary) values('0588dbda3f4d483d84259626c251f072','','','.rpt','','test','','2055291722',1,'??')
No comments:
Post a Comment