May 9, 2013 at 9:15 am
I have a string: '0x0000000000018662' that I want to "use" as a binary: 0x0000000000018662. CONVERT/CAST does not work because, I think, it's converting byte by byte the binary/ascii representation of each character. This seems pretty simple, but I just can't figure out how to get this to work!? Any help would be greatly appreciated!!
May 9, 2013 at 9:35 am
j2cagle (5/9/2013)
I have a string: '0x0000000000018662' that I want to "use" as a binary: 0x0000000000018662. CONVERT/CAST does not work because, I think, it's converting byte by byte the binary/ascii representation of each character. This seems pretty simple, but I just can't figure out how to get this to work!? Any help would be greatly appreciated!!
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',1)
SELECT @VARBINARY
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
May 9, 2013 at 9:42 am
That's what I've been trying, but that results in:
0x30783030303030303030303030313836
May 9, 2013 at 9:46 am
j2cagle (5/9/2013)
That's what I've been trying, but that results in:0x30783030303030303030303030313836
Interesting - I get the same as you if I execute the batch against SQL Server 2000. Against 2k8 it appears to work. Sorry - from here I'd be guessing.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
May 9, 2013 at 9:51 am
I'm using 2008R2. Is there some setting I'm missing??
May 9, 2013 at 9:56 am
When I run the following in SQL Server 2008 R2:
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',1)
SELECT @VARBINARY;
go
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',0)
SELECT @VARBINARY;
go
I get;
0x0000000000018662
0x30783030303030303030303030313836
May 9, 2013 at 9:58 am
Lynn Pettis (5/9/2013)
When I run the following in SQL Server 2008 R2:
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',1)
SELECT @VARBINARY;
go
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',0)
SELECT @VARBINARY;
go
I get;
0x0000000000018662
0x30783030303030303030303030313836
Same here.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
May 9, 2013 at 10:00 am
I get:
0x30783030303030303030303030313836
0x30783030303030303030303030313836
It's almost like the "1" and "0" style options are not recognized?? Any ideas?
May 9, 2013 at 10:02 am
j2cagle (5/9/2013)
I get:0x30783030303030303030303030313836
0x30783030303030303030303030313836
It's almost like the "1" and "0" style options are not recognized?? Any ideas?
Post your code, even if it is identical.
May 9, 2013 at 10:05 am
You say you are using SQL Server 2008 R2. What version of SQL Server are you connected to when you run these?
Run the following:
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',1)
SELECT @VARBINARY;
go
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',0)
SELECT @VARBINARY;
go
select @@version;
go
May 9, 2013 at 10:06 am
I just cut-n-pasted from above:
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',1)
SELECT @VARBINARY;
go
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',0)
SELECT @VARBINARY;
go
May 9, 2013 at 10:08 am
j2cagle (5/9/2013)
I just cut-n-pasted from above:DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',1)
SELECT @VARBINARY;
go
DECLARE @VARBINARY VARBINARY (16)
SET @VARBINARY = CONVERT(VARBINARY (16),'0x0000000000018662',0)
SELECT @VARBINARY;
go
You missed the @@version...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
May 9, 2013 at 10:08 am
Ah ha...that would be the issue...
Version:
Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86) Nov 24 2008 13:01:59 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 6.0 (Build 6001: Service Pack 1)
I know this is a 2008 forum, but is there any ideas for 2005?
May 9, 2013 at 10:11 am
There is no binary conversion style in SQL Server 2005. This was added in SQL Server 2008.
May 9, 2013 at 10:38 am
Is there any "homemade" type solution that can be done in 2005?
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply