x

Reading multiple lines from the queue in service broker in SQL server

I am using the following command to read from the queue. But it returns only one row. I noticed that conversation_handle is unique for all messages. How can I read top 100 or all the rows from the queue in sql server?

RECEIVE *-- @handle=conversation_handle, --@xml=CAST(message_body AS XML) FROM EventData_Destination_Queue
more ▼

asked Aug 31, 2012 at 05:02 PM in Default

pratpk9 gravatar image

pratpk9
0 2 2 2

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

Have you tried:

RECEIVE TOP 100 (*)
FROM EventData_Destination_Queue

Of course this may clear your queue and processing of messages wouldn't be possible.

I imagine in your example only the last message in the queue is displayed. The variables don't hold rowsets, just single values from a given row.
more ▼

answered Aug 31, 2012 at 06:56 PM

Blackhawk-17 gravatar image

Blackhawk-17
11.9k 28 31 36

(comments are locked)
10|1200 characters needed characters left

Greg-- Thanks for your response. Yes I have tried it as well. But still I receive only one row from the query. This is the query I used

RECEIVE * FROM EventData_Destination_Queue
more ▼

answered Aug 31, 2012 at 09:44 PM

pratpk9 gravatar image

pratpk9
0 2 2 2

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x581

asked: Aug 31, 2012 at 05:02 PM

Seen: 684 times

Last Updated: Aug 31, 2012 at 09:44 PM