Home
> Uncategorized > #Base64 decode using #SQL server #UDF
#Base64 decode using #SQL server #UDF
Base64 is a way to encode data into a limited character set, that can allow binary data to be displayed using print-friendly text. For example, if you wanted to represent an image as text, and store it in a database. It does bloat data, but it’s certainly handy when it comes to passing data around.
SQL server doesn’t have a handy function to convert base64 text back into it’s original form, so I decided to write this UDF below;
CREATE FUNCTION dbo.Base64Decode (@Base64 varchar(max))
RETURNS varchar(max)
WITH SCHEMABINDING AS
BEGIN
DECLARE @TEXT AS varchar(max) ;
SELECT
@TEXT = CAST( CAST( @Base64 as XML ).value(‘.’,’varbinary(max)’) AS varchar(max) );RETURN @TEXT ;
END;
GO
Categories: Uncategorized
Hey, you can see more base64 c# examples at this website https://tobase64.dev
LikeLike