Prev: Subquery with Wildcards?
Next: Pink Love-GHD Pink Limited Edition box set with 60% discounts and free shipping
From: SnapDive on 22 Jul 2010 16:46 I am converting a single row of table data into an XML fragment with the below code. The fragment is dumped into a Service Broker queue as a single message. I think I will have to loop through the table to get individual mesages into the queue, since 1 row = 1 message. If there is a way to do this in a set-based manner, please tell me? Thanks. Create Table #stuff ( stuffid int , stuffname varchar(20) , stuffcode int ) Insert Into #stuff values ( 1 , 'aaa' , 3 ) Insert Into #stuff values ( 2 , 'bbb' , 6 ) Insert Into #stuff values ( 3 , 'ccc' , 9 ) Declare @stuffXml Xml = '<?xml version="1.0" encoding="UTF-8" ?>' + Cast ( ( Select * From #stuff where stuffid=1 For Xml Auto , Type , Root('teststuff') ) as VarChar(Max) ) Declare @Handle UniqueIdentifier Begin Dialog Conversation @Handle From Service [stuffservice] To Service 'stuffservice' On Contract [stuffcontract] With Encryption = Off; Send On Conversation @Handle Message Type [stufftype] (@stuffXml); |