Solved

how to Call registered DLL function from T-SQL?

Posted on 2008-10-20
4
427 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
ID: 22760132
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
ID: 22760329
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
ID: 22760723
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

863 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

23 Experts available now in Live!

Get 1:1 Help Now