SQL Server 2000 simplified and Complex Conversion of Chinese character data (COM,. Net)

Source: Internet
Author: User

SQL Server 2000 simplified and Complex Conversion of Chinese character data (COM,. Net)

First, make sure that. NET Framework 1.1 is installed on Windows (of course only the SQL Server server!

After successful installation:
1. Use Sn-K to create a strong-name key file for the Class Library:
Run the following command in the V1.1/bin/subdirectory where the Microsoft. NET Framework SDK is installed:
Sn.exe-k c:/snkey. SNK

2.open the notepad (notepad.exe) and write the following C #ProgramAnd save the file as C:/microshaoft. CS:
Using system;
Using system. runtime. interopservices;
Using system. reflection;
Using system. runtime. compilerservices;

[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 );
/// Simple conversion can also be added with stringconvert parameter control.
}
}
}

3. Run CMD in Windows to go to the command line console and 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/v1.1.4322/Microsoft. visualBasic. DLL
If any error occurs, refer to csc.exe /? Help, or msdn correction!
After you confirm the correct execution, this example will generate the: C:/microshaoft. dll file!

4. Execute the following command line:
C:/Windows/Microsoft. NET/framework/v1.1.4322/regasm.exe C:/microshaoft. dll/TLB: microshaoft. TLB/codebase
After you confirm the correct execution, the Type Library registration is successful and the: C:/microshaoft. TLB file will be generated!

5. Write the following T-SQL to create a function and test the query (SysAdmin members such as SA ):

(T-SQL calls the csdn of COM componentsArticleThere are many for reference)

Create Function udf_stringconvert (@ varchar (8000 ))
Returns varchar (8000)
As
Begin
-- Declare @ varchar (8000)
-- Set @ = 'ajie High Speed'
Declare @ object int
Declare @ HR int
Declare @ source varchar (255), @ description varchar (255)
Declare @ return varchar (8000)
Set @ return =''
Exec @ hR = sp_oacreate 'microshaoft. string', @ object out
If @ 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
End
Else
Begin
Exec @ hR = sp_oageterrorinfo @ object, @ source out, @ description out
Set @ return = @ object + ''+ @ source +'' + @ description
End

Exec @ hR = sp_oadestroy @ object

-- Select @ return
-- Select DBO. udf_stringconvert ('ajie High Speed ')
Return @ return
End

Go

Select DBO. udf_stringconvert ('ajie High Speed ')

Related Article

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.