Showing posts with label sqlscript. Show all posts
Showing posts with label sqlscript. Show all posts

Thursday, March 22, 2012

Converting (too big)Raw into Hex

Hi there,

Here at my work(in Germany) i have a big problem:

Once a week there is a sqlscript, which should run and store data to a txt file.

There is a tablle in which imagedata is stored in RAW format(that one with small boxes, Qmarks and dots...).

Now i want to export it to the txtfile as HEX, so i can decode it by php further.

With the thumbnail, also stores there everything is fine, the SQL looks that way:

SELECt hex(thumbnail) FROM picTable where id_pic=54985

The Data is then displayed as HEX. But the standart picture is to big. When i use the statement:
SELECt hex(bigpic) FROM picTable where id_pic=54985

i got the error message:

An error occurred while running the query.

The data type, length, or value of argument 1 of HEX is invalid.

(SQL code = -171, SQL state = 42815)

After some research i found that the maximum lenght is 16 336 bytes for the HEX-operation. The picture is nearly 30 000 bytes... :shocked:
Have anyone an idea how to fix that?
I am not able here to accsess to the database direct...

I have been working for days on it.Uahh, wrong forum. Can anyone move this to SQL?|||the SQL forum is for standard SQL

i'm guessing you want this moved to the SQL Server forum

:)|||Still not solved...|||What is this "hex" function you are referring to? I could not find any reference to it in BOL (though it certainly would be a handy one to have!).

Regardless, assuming that there actually IS such an animal, can you consider breaking up the input data by sub-sections under your maximum size in the hex() function?

Such as using SUBSTRING ( expression , start , length )?

And then loop until the whole RAW data block is processed completely in bite-size chunks?