• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4153
  • Last Modified:

Insert into column with varbinary datatype

I need a small SQL snippet which will allow me to insert values into fields set as varbinary.  Can anyone help please?

Thanks in advance,

IPT
0
iptrader
Asked:
iptrader
  • 3
  • 2
1 Solution
 
rafranciscoCommented:
create table test101 ( id int, name varchar(30), binarydata varbinary(200))

insert into test101 values (1, 'Name', CAST(123445 AS VARBINARY))
0
 
rafranciscoCommented:
create table test101 ( id int, name varchar(30), binarydata varbinary(200))

insert into test101 values (1, 'Name', CAST(123445 AS VARBINARY))
insert into test101 values (1, 'Name', CAST('ABCDE' AS VARBINARY))
0
 
iptraderAuthor Commented:
Great! It worked.  Can you please also tell me the correct syntax for converting the varbinary data into readable format (for instance, if I want to pass the data into a web browser via ASP).

Thanks a bunch.
0
 
rafranciscoCommented:
Simply reverse it:

SELECT ID, Name, CAST(binarydata as int) FROM Test101
0
 
iptraderAuthor Commented:
Thank you!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now