sql2005clr function Extension-Simplified conversion implementation Code _MSSQL2005

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.