views:

32

answers:

2

Are there any benefits to call CLR SQL stored procedure from regular trigger rather then deploy CLR trigger straight away?

I need to be notified on specific column change (StatusID) in very large table.

Currently a number of windows services is used. Each monitors its own StatusID, i.e. quires db for specific StatusID: SELECT a,b,c FROM t WHERE StatusID = @status.

I want to try move logic from services to SQL CLR assembly and invoke them using SQL CLR trigger. Is it a good idea? Are there better?

+1  A: 

In my opinion, this does not require SQLCLR. However, it depends on what you mean with "being notified". If possible, I'd use a usual trigger and a SQL Agent Job to do the notification.

Florian Reischl
Regular trigger is able to call a regular sp, that's all, right? I need to call a .NET method. I did some research about SQL Broker but it's very complex thing so I think about SQL CLR
abatishchev
Ah, didn't know that "being notified" meant some other .NET code. Though, SQLCLR integration brings up some challenges, as I just wrote here: http://stackoverflow.com/questions/3063081/sql-server-clr-to-embed-business-logic-and-schedule-execution-with-sql-server-age/3312216#3312216 . If possible, try to extract your "notification" from the rest of your code or call (as suggested in the other thread) a SSIS package or command line tool over SQL Agent. I've have no clue about SQL Broker ;-)
Florian Reischl
A: 

If you call the services directly from the CLR you'll have to use a standard SOAP binding, because the CLR only supports .NET 2.0 style Web references.

Using the SQL Server Service broker would be a more robust solution, but as you noted it's complicated. The price you will pay for using the SQLCLR is that your update transactions will be rolled back if you have an unhandled error thrown out of your trigger. Also transaction throughput will certainly be affected if you're blocking for a service call with every update.

Paul Keister
Indeed SQL Server supports .NET version up to 3.5 with some restrictions however.
abatishchev
Last time I checked SQL Server 2008 CLR did not support System.ServiceModel, which rules out WCF. Haven't revisited this issue since R2 was released; hopefully the situation has changed.
Paul Keister

related questions