Michael
Michael

Reputation: 202

insert declared variable into xml code

Hi i want just insert xml variable into xml code.

My code looks like :

DECLARE @outMsg xml
SET @outMsg='<jbpmEngineSignal>
  <type>WORK_ITEM_COMPLETE</type>
  <elementId>257976516</elementId>
  <priority>0</priority>
  <results />
  <tryCount>344</tryCount>
  <uid>7028D745-1C62-46C3-9543-6C1D233450C8</uid>
</jbpmEngineSignal>';

Now i just need to do something like this :

DECLARE @UID xml
set @UID = '7028D745-1C62-46C3-9543-6C1D233450C8'

And finally

DECLARE @outMsg xml
DECLARE @UID xml
set @UID = '7028D745-1C62-46C3-9543-6C1D233450C8'
SET @outMsg='<jbpmEngineSignal>
  <type>WORK_ITEM_COMPLETE</type>
  <elementId>257976516</elementId>
  <priority>0</priority>
  <results />
  <tryCount>344</tryCount>
  <uid>@UID</uid>
</jbpmEngineSignal>';

but this don't work, what am i doing wrong? Can someone just edit my code and show me how to do this ? Thank you. Please be patient for newebies. When you need more info just write in comment :)

Upvotes: 1

Views: 57

Answers (1)

Tyron78
Tyron78

Reputation: 4187

Any reason why you don't use nvarchar for the UID? Then you could it simple as this:

DECLARE @outMsg xml
DECLARE @UID nvarchar(1000);
set @UID = '7028D745-1C62-46C3-9543-6C1D233450C8'
SET @outMsg='<jbpmEngineSignal>
  <type>WORK_ITEM_COMPLETE</type>
  <elementId>257976516</elementId>
  <priority>0</priority>
  <results />
  <tryCount>344</tryCount>
  <uid>' + @UID + '</uid>
</jbpmEngineSignal>';

Upvotes: 1

Related Questions