Invoking C++ Code (or DLL) via Trigger

Invoking C++ Code (or DLL) via Trigger

Question:
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.

Answer:
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.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several