Solved

how to Call registered DLL function from T-SQL?

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

636 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