Procedures for referencing DLLs in SQL Server

Source: Internet
Author: User

referencing DLLs in SQL Server is a two-step process

1. Create a DLL file

2. Put the DLL file into the SQL Server assembly. Then define a function that can be used to refer to the functions in the DLL.

Create a DLL file

1. Click "File", "New", "Project", the class library, change the namespace to Stringhelp, add the following code

namespace Stringhelp                //name Space{     Public  class Classconvert        //class name{//Turn the lowercase letters in the input string into uppercase letters         Public Static string  ToUpper(stringvinputstring)//The function must be a static function, and a static function can be called without instantiating the class.        {            returnVinputstring.toupper (); }    }}

2. Right-click on "Project", click "Generate" or press F6 directly

3. Right click on "Project", click "Open folder in file Resource Management system", click Bin->debug, then you will see a StringHelp.dll file.

referencing DLL files in SQL

1. Introduction of DLL files

Using SQL statements CREATE assembly Testdll from ' C:\Users\ \documents\visual Studio 2012\projects\stringhelp\stringhelp \obj\debug\stringhelp.dll '

Where Testdll is the name you have in the database for this assembly.

Note that if you reference its DLL file in your DLL file, you must refer to its assembly before you introduce the DLL. If your DLL file is using a system.web DLL file, you must do so before referencing Testdll

Reference the system.web DLL file in the same way.

2. Create a function that uses the DLL file

Use the following SQL statement

    

CREATE FUNCTION dbo. ToUpper--The function name (     @InputStringasnvarchar)RETURNS  nvarchar--return type astestdll. [stringhelp.classconvert]

Pay attention to the few words that are marked red.

Testdll refers to the name of the DLL in your assembly.

Stringhelp refers to the namespace of the class in the DLL file

Classconvert refers to the class name of the class in the DLL file.

ToUpper refers to the static method that is called in the DLL file.

Finally, you can call the function like this

print dbo. ToUpper ('abc')

The structure of the output is ABC

Make a little progress every day

2015-03-09

  

Procedures for referencing DLLs in SQL Server

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.