-
Notifications
You must be signed in to change notification settings - Fork 0
/
80_create_vw_list_queues.sql
40 lines (37 loc) · 1.48 KB
/
80_create_vw_list_queues.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/***************************************************************************
- This view can be used to look into both queues at the same time
- Message body can be converted to the corresponding data type
****************************************************************************/
use ServiceBrokerBeginner
go
create or alter view dbo.vwListqueues
as
select
x.message_enqueue_time
,x.service_id
,x.service_name
,x.status
,x.priority
,x.queuing_order
,case x.message_type_name
when 'X' then cast(x.message_body as xml) -- X means it is a validated xml
else cast(x.message_body as nvarchar(4000)) -- otherwise we convert to nvarchar (in case of binary that won't help though
end as message_body
,x.conversation_group_id
,x.conversation_handle
,x.message_sequence_number
,x.service_contract_id
,x.message_type_id
,x.message_type_name
,service_contract_name
,x.validation
from
(
select message_enqueue_time, status, priority, queuing_order, message_body, conversation_group_id, conversation_handle, message_sequence_number
,service_id, service_name, service_contract_id, message_type_id, message_type_name, service_contract_name, validation
from dbo.InitiatorQueue with(nolock)
union all
select message_enqueue_time, status, priority, queuing_order, message_body, conversation_group_id, conversation_handle, message_sequence_number
,service_id, service_name, service_contract_id, message_type_id, message_type_name, service_contract_name, validation
from dbo.TargetQueue with(nolock)
) x