Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SQL Server
Expertise: Beginner
May 5, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Invoking C++ Code (or DLL) via Trigger

Is it possible to have a trigger invoke code in a running application (either via a register-notify type of thing or by calling entry points of a DLL or...)?

I don't want the application to have to poll the database. I'd rather have code in the database "poke" the app.

If you're using C++, you can create extended stored procedures and call them from inside SQL Server. These are stored procedures that are encapsulated in a DLL. Check out the xp_hello extended stored procedure sample that comes with SQL Server.

Once you create the DLL, the stored procedures must be registered in SQL Server (SQL Server BOL has more on the details). Extended stored procedures run in the same address space as SQL Server, so be sure to test them before using them in production.

If you have a Visual Basic or other COM component (DLL), you can call its methods and access its properties using the OLE Automation stored procedures. Using sp_OACreate, sp_OAMethod, and sp_OADestroy, you can create instances of an object and then set and retrieve its properties, as well as call its methods. You can pass parameters into the methods and retrieve values from them.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date