Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
428 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Some other pages relevant to these blogs include:
You can also book hourly online consultancy for your time zone with one of our 7 expert trainers!
|
Changes to SQL introduced in SQL Server 2025 Part five of a five-part series of blogs |
|---|
|
In addition to handling AI models, vectors of data and JSON, SQL now includes a number of other new functions and features (as this blog explains)
|
You can use the following two functions to convert between binary and text formats:
Function | What it does | Accepts | Outputs |
|---|---|---|---|
BASE64_DECODE | Converts text to binary | varchar(n) or varchar(max) | varbinary(8000) or varbinary(max) |
BASE64_ENCODE | Converts binary to text | varbinary(8000) or varbinary(max) | varchar(n) or varchar(max) |
The BASE64_ENCODE function has an additional optional argument which specifies whether the output from the function should be safe to use in a website URL (this defaults to 0, or false). Here's an example of both functions in action:
-- create a variable to hold text in binary format
DECLARE @EncodedOwl as varbinary(max) = Base64_Decode('Wise Owl')
-- create a variable to hold this decoded text
DECLARE @DecodedOwl as nvarchar(max) = Base64_Encode(@EncodedOwl)
-- show these two variables
SELECT
'Wise Owl' as 'original',
@EncodedOwl as 'As binary',
@DecodedOwl as 'As text'
Here's what this SQL would give:

The result from running this function (notice that we haven't quite got back what we started with).
This function will be most useful for converting binary data like images to text format for (say) emailing; the results can then be re-encoded back to binary by the recipient.
| Parts of this blog |
|---|
|
Some other pages relevant to these blogs include:
You can also book hourly online consultancy for your time zone with one of our 7 expert trainers!
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2025. All Rights Reserved.