Solved

Using service broker in sql server 2005

Posted on 2013-01-13
8
392 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
ID: 38772832
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
ID: 38773241
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
ID: 38775282
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 42

Expert Comment

by:EugeneZ
ID: 38781968
<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
ID: 38798588
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
ID: 38799852
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
ID: 38977349
Thank you
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

813 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

11 Experts available now in Live!

Get 1:1 Help Now