Getting the text encoded value of a jpg file...

C

Charlie@CBFC

Hi:

I want to set a default value of a varbinary(max) column in SQL Server. The
reason is my application databinds to a varbinary(max) column to display
pictures, and if there is no picture when record is created, I would like it
to default to a common picture. To do this, I will need text encoded
equivalent of binary file so I can paste it in as a column default. How do
I do this?

Thanks,
Charlie
 
B

bruce barker

do a hex dump of the image. then use this syntax:

insert table (@id, 0xfffffffffff)
 
M

manit77

Hi:

I want to set a default value of a varbinary(max) column in SQL Server. The
reason is my application databinds to a varbinary(max) column to display
pictures, and if there is no picture when record is created, I would like it
to default to a common picture. To do this, I will need text encoded
equivalent of binary file so I can paste it in as a column default. How do
I do this?

Thanks,
Charlie

Why don't you upload the default file to your database and have it as
ID of 0. Then in control the insert of the default image in your SP,
if the jpg is dbnull then do an insert of the default file you have
you in your database.

if( @filedata is null)

select @imagedata=data from files where id=0


insert into files(imagedata) values(@imagedata)



- Manit
http://www.acriticsreview.com
 
C

Charlie@CBFC

Thanks guys. I downloaded a hex editor to get at the code.

Used it in SP. Works great.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top