Solved

how to Call registered DLL function from T-SQL?

Posted on 2008-10-20
4
428 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Backup & Restore 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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

813 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

12 Experts available now in Live!

Get 1:1 Help Now