Solved

how to Call registered DLL function from T-SQL?

Posted on 2008-10-20
4
431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

740 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