SQL Server 2000 Chinese Character Data Data Data Extra-relaying Conversion Example (COM, .NET)
First confirm that the .NET Framework 1.1 is installed on Windows (of course only the server side of SQL Server)!
After confirming successful installation: 1. Create a strong name key file with SN -K: Enter the following command line under the V1.1 / bin / subdirectory in the directory where Microsoft .NET Framework SDK is installed: SN .exe -kc:/snkey.snk
2. Open Notepad.exe to write the following C # program and save the file for c: / microshaoft.cs: use system; using system.Runtime.InterOpServices; useing system.Runtime.CompilerVices;
[Assembly: AssemblyKeyFile ("snkey.snk")]]
namespace Microshaoft {public interface IStrings {string StringConvert (string x);} [ClassInterface (ClassInterfaceType.AutoDual)] public class Strings: IStrings {public string StringConvert (string x) {return Microsoft.VisualBasic.Strings.StrConv (x, Microsoft. VisualBasic.vbstrConv.traditionalChinese, System.globalization.cultureInfo.currentculture.lcid); // // Difficult Conversion can also be StringConvert to add parameter control, not to deene each other}}}
3. Run the CMD under Windows to enter the command line console, execute the following command line: c: /windows/microsoft.net/framework/v1.1.4322/csc.exe / t: library /out:c:/microshaoft.dll C : / Microshaoft.cs /R:c:/Windows/Microsoft.net/framework/viisualbasic.dll If there is any error, please refer to CSC.EXE /? Help, or MSDN correction! Confirm that the correct execution, this Case will generate: c: /placeroshaoft.dll file!
4. Perform the following command line: c: /windows/microsoft.net/framework/v1.1.4322/Regasm.exe C: /Microshaoft.dll /tlb:/microshaoft.tlb / codebase confirmed that the type library was successfully registered, Generate: c: /microshaoft.tlb file!
5. Write the following T-SQL creation functions and test query (members of Sysadmin, such as SA):
(T-SQL calls COM components have a lot of available references)
create function UDF_StringConvert (@ varchar (8000)) returns varchar (8000) asbegin - DECLARE @ varchar (8000) --set @ = 'high speed Liza' DECLARE @object intDECLARE @hr intDECLARE @source varchar (255), @description varchar (255) DECLARE @Return varchar (8000) set @return = '' EXEC @hr = sp_OACreate 'microshaoft.strings', @object oUTIF @hr = 0 begin EXEC @hr = sp_OAMethod @object, 'StringConvert', @return OUT, @ IF @hr <> 0 begin EXEC @hr = sp_OAGetErrorInfo @object, @source OUT, @description OUT set @return = @object '' @source '' @description end endelse begin EXEC @ HR = sp_oageterrorinfo @Object, @Source Out, @Description out set @return = @object '' @Source '' @Description endexec @object = sp_oadestroy @Object
--Select @ Return - Select dbo.udf_stringconvert ('Ai speed is extremely high "Return @returne
Go
SELECT DBO.UDF_STRINGCONVERT ('A sister speed is very high ")