Solved

how to Call registered DLL function from T-SQL?

Posted on 2008-10-20
4
425 Views
Last Modified: 2010-08-05
Hello Experts,

I have created one DLL in .NET which has only one function in it which sends email with SMTP. Function name is SendMail which accepts parameters like to, from, subject, SMTP servername, UserName and other.

Now if i register that DLL on my SQL server then can i call that SendMail function from my T-SQL code and pass those parameters values from Query it self?

I know its possible but how to achieve that i do not know. So, please Experts do the needfull.

Thanks in Advance and Regards.
0
Comment
Question by:PresageSolutions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:randy_knight
Comment Utility
I assume this is SQL Server 2005?  If so, you can register a .net assembly with CREATE ASSEMBLY.  However, I wonder why you would not just use database mail for this?

If this is SQL Server 2000, you will need to create your dll as an extended stored procedure, which must be written in C++.  No .NET CLR in SQL Server 2000.
0
 

Author Comment

by:PresageSolutions
Comment Utility
Sorry for not being specific.

Its not SQL Server 2005. We are running on SQL server 2000 with SP4.

And if i am not wrong then we can call any function of registered DLL within our SQL. I just forgot the steps how to do that.

We can just pass the name of the DLL and name of the function and then Argument list but excat procedure i forgot.

Please help....
0
 
LVL 4

Accepted Solution

by:
randy_knight earned 125 total points
Comment Utility
If it's a COM dll you can use sp_oaCreateObjec (something close to that anyway).  But it is not recommended as your dll code runs in-process with sqlserver.exe in that case.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now