Link to home
Start Free TrialLog in
Avatar of iptrader
iptrader

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of rafrancisco
rafrancisco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rafrancisco
rafrancisco

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))
Avatar of iptrader

ASKER

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.
Simply reverse it:

SELECT ID, Name, CAST(binarydata as int) FROM Test101
Thank you!!!