Raising Events in a SQL Server trigger
Nicolas Galler | August 31, 2007For SQL 2005 you could do that from .NET obviously. But in SQL 2000 you have to resort to a shell command or an extended proc. I finally bit the bullet and researched how to create an extended proc, it was pretty easy. I just followed the instructions in MSDN, and used the following code in my proc:
__declspec(dllexport) SRVRETCODE xp_sss_raiseProcessQueueEvent(SRV_PROC * proc)
{
HANDLE evt = OpenEvent(EVENT_MODIFY_STATE, false, TEXT("SSSWorld.Rtsn.ProcessQueueEvent"));
if(evt != NULL){
SetEvent(evt);
CloseHandle(evt);
}
return 0;
}
One catch is that despite the __declspec magic, I had to create a .def file in order for SQL server to recognize the function. I probably missed some VC++ switch, but hey, this works.





