This method is relatively simple, with the Microsoft.VisualBasic namespace under the powerful string processing functions can be
C # code is as follows, compiled to BigConvertor.dll
--------------------------------------------------------------------------------
Copy Code code as follows:
Using System;
Using System.Data.SqlTypes;
Using Microsoft.SqlServer.Server;
public partial class Userdefinedfunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString BIGTOGB (SqlString instring)
{
if (instring.isnull) return SqlString. Null;
Return (Microsoft.VisualBasic.Strings. StrConv (Instring.value, Microsoft.VisualBasic.VbStrConv. SimplifiedChinese, 0));
}
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString Gbtobig (SqlString instring)
{
if (instring.isnull) return SqlString. Null;
Return (Microsoft.VisualBasic.Strings. StrConv (Instring.value, Microsoft.VisualBasic.VbStrConv. TraditionalChinese, 0));
}
};
--------------------------------------------------------------------------------
The deployment code is as follows
--------------------------------------------------------------------------------
Copy Code code as follows:
CREATE ASSEMBLY bigconvertor from ' e:/sqlclrdata/bigconvertor.dll ' with permission_set = UnSAFE;
--
Go
The CREATE FUNCTION dbo. Xfn_bigtogb
(
@value nvarchar (max)
)
RETURNS nvarchar (max)
As EXTERNAL NAME Bigconvertor. Userdefinedfunctions. Bigtogb
Go
The CREATE FUNCTION dbo. Xfn_gbtobig
(
@value nvarchar (max)
)
RETURNS nvarchar (max)
As EXTERNAL NAME Bigconvertor. Userdefinedfunctions. Gbtobig
Go
--------------------------------------------------------------------------------
The test code is as follows
--------------------------------------------------------------------------------
* * Test/*
SELECT dbo. Xfn_gbtobig (' conversion of simplified and traditional text ')
--the transformation of simplicity and complexity
SELECT dbo. XFN_BIGTOGB (' Simplified and complex transformation ')
--the conversion of simplified and traditional texts