[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

JPGs added to Image column are truncated at 1024 bytes (but only when import executed as a Job

Laurence Neville

3/26/2007 2:28:00 PM

I have a table in a SQL 2005 database that is designed to hold JPG product
images for a website. Here is the schema:

create table dbo.Eur_RMISWebInterface_Staging_ProductImages(
product_code varchar(12) not null,
image_order smallint not null,
colour_identifier varchar(10) not null,
image_data image not null,
constraint PK_Eur_RMISWebInterface_Staging_ProductImages primary key
clustered (
product_code,
image_order
)
)

Product images are inserted into the table from a database on a remote SQL
2000 server. Here is the script that does that (uses dynamic SQL):

set @SQLCmd = '
set xact_abort on

begin transaction

delete Eur_RMISWebInterface_Staging_ProductImages

insert Eur_RMISWebInterface_Staging_ProductImages (
product_code,
image_order,
colour_identifier,
image_data
)
exec "' + @RMISServerName + '".' + @RMISDatabaseName +
'.dbo.Eur_RMISWebInterface_GetProductImagesForWeb ' + convert(varchar(3),
@PortalID) + ', ' + @Locale_LCID + '

commit transaction'
execute (@SQLCmd)

About 500 images, each about 20KB, are transferred at a time. Here is the
problem - when this script is run manually, all the images are inserted
completely. When the script is run as part of a job (that has several other
steps), the job step completes successfully and all the images are inserted,
but every single one is truncated to the first 1024 bytes of the image. What
this ends up looking like on the website is a a narrow strip of image
instead of a complete image. Here are some other observations:

- When I changed the "Eur_RMISWebInterface_GetProductImagesForWeb" SP to
only return 1 product image instead of 500 it still failed
- The owner of the job is the same Windows user as the user I have been
running the script manually as
- I have tried changing the datatype of image_data from image to
varbinary(max) but it made no difference

What could possibly be going on???


3 Answers

Mark Yudkin

3/26/2007 5:42:00 PM

0

SET TEXTSIZE ?

"Laurence Neville" <laurenceneville@hotmail.com> wrote in message
news:OZjGhO7bHHA.4832@TK2MSFTNGP02.phx.gbl...
>I have a table in a SQL 2005 database that is designed to hold JPG product
>images for a website. Here is the schema:
>
> create table dbo.Eur_RMISWebInterface_Staging_ProductImages(
> product_code varchar(12) not null,
> image_order smallint not null,
> colour_identifier varchar(10) not null,
> image_data image not null,
> constraint PK_Eur_RMISWebInterface_Staging_ProductImages primary key
> clustered (
> product_code,
> image_order
> )
> )
>
> Product images are inserted into the table from a database on a remote SQL
> 2000 server. Here is the script that does that (uses dynamic SQL):
>
> set @SQLCmd = '
> set xact_abort on
>
> begin transaction
>
> delete Eur_RMISWebInterface_Staging_ProductImages
>
> insert Eur_RMISWebInterface_Staging_ProductImages (
> product_code,
> image_order,
> colour_identifier,
> image_data
> )
> exec "' + @RMISServerName + '".' + @RMISDatabaseName +
> '.dbo.Eur_RMISWebInterface_GetProductImagesForWeb ' + convert(varchar(3),
> @PortalID) + ', ' + @Locale_LCID + '
>
> commit transaction'
> execute (@SQLCmd)
>
> About 500 images, each about 20KB, are transferred at a time. Here is the
> problem - when this script is run manually, all the images are inserted
> completely. When the script is run as part of a job (that has several
> other steps), the job step completes successfully and all the images are
> inserted, but every single one is truncated to the first 1024 bytes of the
> image. What this ends up looking like on the website is a a narrow strip
> of image instead of a complete image. Here are some other observations:
>
> - When I changed the "Eur_RMISWebInterface_GetProductImagesForWeb" SP to
> only return 1 product image instead of 500 it still failed
> - The owner of the job is the same Windows user as the user I have been
> running the script manually as
> - I have tried changing the datatype of image_data from image to
> varbinary(max) but it made no difference
>
> What could possibly be going on???
>


Erland Sommarskog

3/26/2007 10:17:00 PM

0

Laurence Neville (laurenceneville@hotmail.com) writes:
> I have a table in a SQL 2005 database that is designed to hold JPG product
> images for a website. Here is the schema:
>
> create table dbo.Eur_RMISWebInterface_Staging_ProductImages(
> product_code varchar(12) not null,
> image_order smallint not null,
> colour_identifier varchar(10) not null,
> image_data image not null,
> constraint PK_Eur_RMISWebInterface_Staging_ProductImages primary key
> clustered (
> product_code,
> image_order
> )
> )

If this table is only on SQL 2005, why use image, and not varbinary(MAX)?
This data type is new on SQL 2005 and is equivalent to image in size,
but does not have the antics of the older and now deprecated type.

> set @SQLCmd = '
> set xact_abort on
>
> begin transaction
>
> delete Eur_RMISWebInterface_Staging_ProductImages
>
> insert Eur_RMISWebInterface_Staging_ProductImages (
> product_code,
> image_order,
> colour_identifier,
> image_data
> )
> exec "' + @RMISServerName + '".' + @RMISDatabaseName +
> '.dbo.Eur_RMISWebInterface_GetProductImagesForWeb ' + convert(varchar(3),
> @PortalID) + ', ' + @Locale_LCID + '
>
> commit transaction'
> execute (@SQLCmd)

You should not really need to use dynamic SQL, since all that is
dynamic is the procedure name. This can behandled this way:

@spname = @RMISServerName + '.' + @RMISDatabaseName +
'.dbo.Eur_RMISWebInterface_GetProductImagesForWeb'
EXEC @spname @PortalID, @Local_LCID


> About 500 images, each about 20KB, are transferred at a time. Here is
> the problem - when this script is run manually, all the images are
> inserted completely. When the script is run as part of a job (that has
> several other steps), the job step completes successfully and all the
> images are inserted, but every single one is truncated to the first 1024
> bytes of the image.

None of the points I mentioned above are likely to address this issue,
Mark's guess on SET TEXTSIZE seems like a good one to try.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/...
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/...

Laurence Neville

3/27/2007 10:02:00 AM

0

The answer was SET TEXT SIZE. I added the following before the Insert and
the images are now complete:

set textsize 1000000

Thanks for the SQL tips also!



"Erland Sommarskog" <esquel@sommarskog.se> wrote in message
news:Xns990029D8557AYazorman@127.0.0.1...
> Laurence Neville (laurenceneville@hotmail.com) writes:
>> I have a table in a SQL 2005 database that is designed to hold JPG
>> product
>> images for a website. Here is the schema:
>>
>> create table dbo.Eur_RMISWebInterface_Staging_ProductImages(
>> product_code varchar(12) not null,
>> image_order smallint not null,
>> colour_identifier varchar(10) not null,
>> image_data image not null,
>> constraint PK_Eur_RMISWebInterface_Staging_ProductImages primary key
>> clustered (
>> product_code,
>> image_order
>> )
>> )
>
> If this table is only on SQL 2005, why use image, and not varbinary(MAX)?
> This data type is new on SQL 2005 and is equivalent to image in size,
> but does not have the antics of the older and now deprecated type.
>
>> set @SQLCmd = '
>> set xact_abort on
>>
>> begin transaction
>>
>> delete Eur_RMISWebInterface_Staging_ProductImages
>>
>> insert Eur_RMISWebInterface_Staging_ProductImages (
>> product_code,
>> image_order,
>> colour_identifier,
>> image_data
>> )
>> exec "' + @RMISServerName + '".' + @RMISDatabaseName +
>> '.dbo.Eur_RMISWebInterface_GetProductImagesForWeb ' + convert(varchar(3),
>> @PortalID) + ', ' + @Locale_LCID + '
>>
>> commit transaction'
>> execute (@SQLCmd)
>
> You should not really need to use dynamic SQL, since all that is
> dynamic is the procedure name. This can behandled this way:
>
> @spname = @RMISServerName + '.' + @RMISDatabaseName +
> '.dbo.Eur_RMISWebInterface_GetProductImagesForWeb'
> EXEC @spname @PortalID, @Local_LCID
>
>
>> About 500 images, each about 20KB, are transferred at a time. Here is
>> the problem - when this script is run manually, all the images are
>> inserted completely. When the script is run as part of a job (that has
>> several other steps), the job step completes successfully and all the
>> images are inserted, but every single one is truncated to the first 1024
>> bytes of the image.
>
> None of the points I mentioned above are likely to address this issue,
> Mark's guess on SET TEXTSIZE seems like a good one to try.
>
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/...
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/...