Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Convert Varchar to Varbinary(Max)

Author  Topic 

shankbond
Starting Member

5 Posts

Posted - 2009-12-21 : 07:46:15
hi,

is it possible to convert a varchar(8000) to varbinary(max)?

I cannot use Convert and Cast functions,because msdn says that these functions cannot convert Varchar to Varbinary. Is there some different way I can convert it?

Any help shall be appreciated

Thanks

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-21 : 07:53:14
Hi

You mean this..

DECLARE @X VARCHAR(8000)
SET @X = 'TESTING'
SELECT @X AS [VARCHAR], CAST(@X AS VARBINARY(MAX)) AS [VARBINARY]



-------------------------
R...
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-21 : 10:42:02
quote:
Originally posted by shankbond

hi,

is it possible to convert a varchar(8000) to varbinary(max)?

I cannot use Convert and Cast functions,because msdn says that these functions cannot convert Varchar to Varbinary.



where does it say that?
see here: http://msdn.microsoft.com/en-us/library/ms187928.aspx
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-12-21 : 10:45:06
Perhaps he's confused varchar with sql_variant?

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

mldardy
Starting Member

13 Posts

Posted - 2009-12-21 : 11:18:25
quote:
Originally posted by jimf

Perhaps he's confused varchar with sql_variant?

Jim

Everyday I learn something that somebody else already knew


Perhaps you don't know what you are talking about.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-21 : 12:01:49
wow. no need for that. perhaps you should have more than 9 posts b4 you start flaming people up
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-12-21 : 12:32:11
That's okay. He's teaching me how to be more mature. I look forward to further instruction.

jim

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=137470

Everyday I learn something that somebody else already knew
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-21 : 14:57:54
lol. nice.
Go to Top of Page

shankbond
Starting Member

5 Posts

Posted - 2009-12-22 : 05:46:52
May be I misinterpreted or misunderstood the MASN link, here is the link where i got confused.
http://msdn.microsoft.com/en-us/library/ms191530.aspx.

Now the problem is solved as I did more research on Convert and Cast.
Thanks a lot anyways :)
Go to Top of Page
   

- Advertisement -