Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Insert into column with varbinary datatype

Posted on 2005-04-29
5
Medium Priority
?
4,149 Views
Last Modified: 2012-06-21
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
Comment
Question by:iptrader
  • 3
  • 2
5 Comments
 
LVL 28

Accepted Solution

by:
rafrancisco earned 2000 total points
ID: 13896522
create table test101 ( id int, name varchar(30), binarydata varbinary(200))

insert into test101 values (1, 'Name', CAST(123445 AS VARBINARY))
0
 
LVL 28

Expert Comment

by:rafrancisco
ID: 13896534
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
 

Author Comment

by:iptrader
ID: 13896599
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
 
LVL 28

Expert Comment

by:rafrancisco
ID: 13896620
Simply reverse it:

SELECT ID, Name, CAST(binarydata as int) FROM Test101
0
 

Author Comment

by:iptrader
ID: 13896644
Thank you!!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question