Service Broker - Always check @@rowcount - SimonS Blog on SQL Server Stuff

Service Broker - Always check @@rowcount

If you're using service broker you will may be using activation to have a stored procedue read messages off a queue. If you are make sure you are aware that you activation procedure will be activated at times even when they're are no messages.

For this reason your logic should always be,

RECEIVE ....message

IF @@ROWCOUNT =1

  BEGIN

 --do youre processing.

  END

This was following a post on the forums http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=900891&SiteID=1&mode=1

Remus has a better framework for an activation procedure and can be found here only with examples of the fastest way of reading from the queue.

http://blogs.msdn.com/remusrusanu/archive/2006/10/14/writing-service-broker-procedures.aspx

-
Published 07 November 2006 23:50 by simonsabin

Comments

No Comments