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