August 31, 2009 at 6:55 pm
Hi,
I have a small table in which i will be inserting the data.I want to convert this data to binary and store as binary.I tried some approaches but nothin seems to work.This will be live table which will be storing user information as they put in the application .THe table only has 8 columns so pretty small.
I am just looking for some way to convert to binary usising T-sql.
Any help is appreciated.
August 31, 2009 at 7:56 pm
here's the example i always reference from my snippets:
DECLARE @var VARBINARY(128),
@res NVARCHAR(64)
SET @var = CAST(N'Hello World' AS VARBINARY(128))
PRINT @var
--results: 0x480065006C006C006F00200057006F0072006C006400
SET @res = CAST(@var AS NVARCHAR(64))
PRINT @res
--results: Hello World
--The same but using CONVERT:
SET @var = CONVERT(VARBINARY(128), (N'Bananas and Oranges'))
PRINT @var
--results: 0x420061006E0061006E0061007300200061006E00640020004F00720061006E00670065007300
SET @res = CONVERT(NVARCHAR(64),@var)
PRINT @res
--results: Bananas and Oranges
Lowell
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply