?
Solved

Using service broker in sql server 2005

Posted on 2013-01-13
8
Medium Priority
?
404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 10

Expert Comment

by:Matt Bowler
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 1500 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 43

Expert Comment

by:Eugene Z
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 1500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

764 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