Convert VarcharBinary To Original String

Rajnilari2015
Posted by Rajnilari2015 under Sql Server category on | Points: 40 | Views : 1447
The below SQL code will do so

DECLARE @t TABLE(Id INT IDENTITY, ColVarBinaryData VARBINARY(MAX))
INSERT INTO @T Select CAST('Hello How R U' AS VARBINARY(MAX)) UNION ALL SELECT CAST('I am fine..Thanks' AS VARBINARY(MAX))

Select
*
, OriginalString = CAST(ColVarBinaryData AS VARCHAR(MAX))
From @T


Result
==========
Id	ColVarBinaryData	                       OriginalString
1 0x48656C6C6F20486F7720522055 Hello How R U
2 0x4920616D2066696E652E2E5468616E6B73 I am fine..Thanks

Comments or Responses

Login to post response