query to convert varchar datatype to varbinary

Posted by Parthibansk under Sql Server on 1/7/2013 | Points: 10 | Views : 3859 | Status : [Member] | Replies : 3
need a query to convert varchar datatype to varbinary..




Responses

Posted by: mohammedr88-18313 on: 1/7/2013 [Member] Starter | Points: 25

Up
0
Down


declare @var varchar(20)='ab' -- the varchar
select convert(varbinary ,@var) -- converted to varbinary

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kundan64 on: 1/8/2013 [Member] Starter | Points: 25

Up
0
Down
You can also use the CAST method for the conversion:

Select CAST(@var as Varbinary)


Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shubh on: 1/11/2013 [Member] Starter | Points: 25

Up
0
Down
Hi friend
i think it helps you

INSERT INTO BLOBTest
(BLOBName, BLOBData)
SELECT 'First test file',
BulkColumn FROM OPENROWSET(
Bulk 'C:\temp\nextup.jpg', SINGLE_BLOB) AS BLOB

Shubham Agrahari

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response