Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


TSQL Challenge 51 - Convert long Binary strings to Decimal strings


TSQL Challenge 51 - Convert long Binary strings to Decimal strings

Author
Message
jacob sebastian
jacob sebastian
SSC-Addicted
SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)

Group: General Forum Members
Points: 472 Visits: 2523
Comments posted to this topic are about the item TSQL Challenge 51 - Convert long Binary strings to Decimal strings

.
sample1
sample1
Right there with Babe
Right there with Babe (775 reputation)Right there with Babe (775 reputation)Right there with Babe (775 reputation)Right there with Babe (775 reputation)Right there with Babe (775 reputation)Right there with Babe (775 reputation)Right there with Babe (775 reputation)Right there with Babe (775 reputation)

Group: General Forum Members
Points: 775 Visits: 266
Not able to reach the site with the link provided the Site. The answer could be

;WITH CTE
AS
(
SELECT SEQ, BINARYVALUE, 0 AS EXPO, CONVERT(NVARCHAR(4000),RIGHT(BINARYVALUE,1)) REMAINING
, CONVERT(NVARCHAR(4000),LEFT(BINARYVALUE,LEN(BINARYVALUE) - 1)) DEDUCTIBLE
FROM TC51

UNION ALL

SELECT SEQ, BINARYVALUE, EXPO + 1, CONVERT(NVARCHAR(4000),RIGHT(DEDUCTIBLE,1))
,CONVERT(NVARCHAR(4000),LEFT(DEDUCTIBLE,LEN(DEDUCTIBLE) - CASE WHEN LEN(DEDUCTIBLE) > 0 THEN 1 ELSE 0 END )) DEDUCTIBLE

FROM CTE
WHERE LEN(DEDUCTIBLE) > 0
)

sELECT SUM(remaining * power(CONVERT(NUMERIC(18,0),2),expo)),seq, binaryvalue
FROM CTE
group by seq, binaryvalue
order by seq, binaryvalue

If there is any better method, please let me know how can I view it?
jacob sebastian
jacob sebastian
SSC-Addicted
SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)

Group: General Forum Members
Points: 472 Visits: 2523
Most people submit their solutions in the first two weeks after the challenge is published. The evaluation then might take another 2-4 weeks to complete. The solutions will be available publicly after the evaluation is completed.

I would encourage you to go to http://beyondrelational.com/puzzles/sqlserver/tsql/51/submit.aspx and submit your solution.

.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search