Solved

Using service broker in sql server 2005

Posted on 2013-01-13
8
390 Views
Last Modified: 2013-03-12
Hi Experts,

I am new to service broker and using event/subscriber process I need to do below task.

For example:
Whenever a change is made to  a table (test) in test_db ,we need to insert records into  two tables (demo,sample) of another database demo_db using event/subscriber process
I was told to create stored procedures for eventsubscribe,eventunsubscribe etc to achieve this.

Can anyone share the code(sql scripts) for the above task?
0
Comment
Question by:ksd123
8 Comments
 
LVL 9

Expert Comment

by:MattSQL
Comment Utility
There is actually a bit of setup involved with service broker 2005. One good place to start is with the templated queries in SSMS:

http://msdn.microsoft.com/en-us/library/ms179334(v=sql.90).aspx
0
 
LVL 12

Assisted Solution

by:Saurabh Bhadauria
Saurabh Bhadauria earned 500 total points
Comment Utility
I guess your databases are residing on single server. you can configure service broker a databases like in below link....

http://www.mssqltips.com/sqlservertip/1836/sql-server-service-broker-example-on-how-to-configure-send-and-receive-messages/

You can create trigger on you first table to feed records in initiators queue..

Do some research and let me know if you required further guidance...

Thanks,
Saurabh
0
 

Author Comment

by:ksd123
Comment Utility
Hi Saurabh,

Could you please elaborate me how many triggers/stored procedures message types/contracts/queues/services required  on both source and destination database's needed to achieve above task?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
<Whenever a change is made to  a table (test) in test_db >


try to use triggers:
Audit table data changes in SQL Server 2005
http://codeinet.blogspot.com/2006/09/audit-table-data-changes-in-sql-server.html
0
 

Author Comment

by:ksd123
Comment Utility
Hi ,

I have created trigger on the first table  and suggest me on the next steps
(how many Messages,queues,services,SP's) needed to achieve above task
0
 
LVL 12

Accepted Solution

by:
Saurabh Bhadauria earned 500 total points
Comment Utility
look at the below link....to undrstand the architecture of Service broker...

http://www.codeproject.com/Articles/11795/Introducing-Distributed-Messaging-using-Service-Br

You gonna required at least one message type of each initiator and on target...Same with the Queue and Service .. It's also obvious in first link...
like
-Create Service for the Initiator.
CREATE SERVICE [//SBTest/SBSample/SBInitiatorService]
ON QUEUE SBInitiatorQueue;
--Create Service for the Target.
CREATE SERVICE [//SBTest/SBSample/SBTargetService]
ON QUEUE SBTargetQueue
([//SBTest/SBSample/SBContract]);



On SP : once message is reached on target from initiator , a Sp is required at target to handle message. Similarly if you want to send a message acknowledgement to initiator from target then you gonna required a SP at initiator end as well

Thanks,
Saurabh
0
 

Author Closing Comment

by:ksd123
Comment Utility
Thank you
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now