代码如下:
源代码:
CREATE FUNCTION [dbo].[svf_StringToBase64] ( @input NVARCHAR(MAX) ) RETURNS NVARCHAR(MAX) AS BEGIN RETURN (SELECT CAST(@input AS VARBINARY(MAX)) FOR XML PATH('')) END GO CREATE FUNCTION [dbo].[svf_Base64ToString] ( @input NVARCHAR(MAX) ) RETURNS NVARCHAR(MAX) AS BEGIN RETURN (SELECT CAST(CAST(@input AS XML).value('.','VARBINARY(MAX)') AS NVARCHAR(MAX))) END GOSource Code
实例:
源代码:
SELECT [dbo].[svf_StringToBase64] (N'insus.net@中国') GO SELECT [dbo].[svf_Base64ToString] (N'aQBuAHMAdQBzAC4AbgBlAHQAQAAtTv1W') GOSource Code