Integer data type -> binary coded decimal

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Ali Cox (REEMOVETHIIS_alastair_cox_at_btinternet.com)
Date: 03/20/04


Date: Sat, 20 Mar 2004 03:56:06 -0800

I'm trying to create the binary coded decimal representation of a decimal integer, to be used/cast in a varchar concat with others of the same.
Basically this is to decode MIME base64 encoding, and I have hit the proverbial brick wall with this part of it.

EG. 34 (dec) is 100010 (bcd)

I need to take the int 34, and change to the string '100010'.

I hope there is a neat way to do this, perhaps mathematically?, as I don't really want to use a case statement. I can't see any datatype in SQL2K (Intel x86) that I can use.

Thanks,
Ali.