April 1, 2015 at 2:14 am
Trying to get this query to work, converting a binary version string to human readable output but somehow it doesn't work, any ideas?
😎
/* Version number binary from daily registy */
DECLARE @VERSION_STRING VARBINARY(16) = 0x4D5544532556564C5B504C552D675B;
/* Inline Tally for parsing the binary string */
;WITH T(N) AS (SELECT N FROM (VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL)) AS X(N))
,NUMS(N) AS (SELECT TOP(DATALENGTH(@VERSION_STRING)) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS N FROM T T1,T T2)
/* Human readable output */
SELECT
(
SELECT
CHAR(ASCII(SUBSTRING(@VERSION_STRING,NM.N,1)) - NM.N)
FROM NUMS NM
ORDER BY (NM.N % (DATALENGTH(@VERSION_STRING) / 4)) % (DATALENGTH(@VERSION_STRING) / 3)
FOR XML PATH(''),TYPE
).value('.[1]','VARCHAR(24)') AS VERSION_NAME;
April 1, 2015 at 7:59 am
Very nice. Glad I tried running it before spending any time trying to break the query down.
April 1, 2015 at 9:08 am
HA! Very nice.
April 1, 2015 at 9:09 am
Very nice. You got a lot of cool stuff in there.
April 1, 2015 at 9:32 am
Yes it is nice.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 1, 2015 at 1:05 pm
Little bit of giggle but more like crypto 101 with some artificial complexity sprinkled on top;-)
😎
April 2, 2015 at 9:53 am
Nice!
-- Itzik Ben-Gan 2001
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply