Posted on

Base 64 encoding is the process of converting bytes (8 bits) to readable, printable characters. To do this, 64 possible characters are used (6 bits), and every 3 bytes translates into 4 characters.

SQL Server generally shouldn’t need to do this. Storing binary in the database is just fine – but if you need it, here’s one way to do it.

There’s another XML function you could do, something like xs:base64Binary – or you could also use a CLR function – but this is a pretty easy way to go.

View code on GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *