Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to push inserted data out of SQL Server to an application?

I would like to use some mechanism within SQL Server (or one of its services) to push change messages out (via UDP, for example, but TCP is OK, too) when rows get inserted into a table. I would like for these messages to be more than notifications of change, but to actually contained the changed data. Is there a mechanism that comes with SQL Server 2008 R2 to do this? I've heard of Service Broker and Extended Events, but am not sure that these are the right tools for the job when it comes to getting near real time data pushed out of SQL Server to another app that needs to update its internal state when data in SQL Server changes, without having to query SQL Server (i.e., I want the data to be strictly pushed out of SQL Server).

I the worst case, I can write SQLCLR code that unicasts UDP messages containing changes, but I would like to reuse an existing service, if available.

like image 880
Michael Goldshteyn Avatar asked Jun 09 '11 18:06

Michael Goldshteyn


2 Answers

Since you are using SQL 2008, Change Tracking is built right in.

MSDN provides extensive information on enabling and implementing the feature. This overview article provides a high level view and this article is a great place to start on the implementation.

like image 61
Jonathan Van Matre Avatar answered Sep 20 '22 20:09

Jonathan Van Matre


Unfortunately, because SQL Server Notification Services was removed from 2008 and later, there really isn't a good built-in way to do this. Microsoft's official party line is that Reporting Services can fill the gap, but practical experience proves otherwise.

You're stuck with either a 3rd party solution or rolling your own. Good luck!

like image 29
Brad Divine Avatar answered Sep 19 '22 20:09

Brad Divine