title: Get SQL xml attribute value using variable
body: <p>I have a SQL function that takes a variable called <code>attribute</code>, which is the xml attribute I want to get the value from. <code>xmlPath</code> is the full XML string. </p>
  
  <p>My xml looks like this:</p>
  
  <pre><code>&lt;EventSpecificData&gt;
    &lt;Keyword&gt;
      &lt;Word&gt;myWord&lt;/Word&gt;
      &lt;Occurences&gt;1&lt;/Occurences&gt;
      &lt;Context&gt;context&lt;/Context&gt;
    &lt;/Keyword&gt;
  &lt;/EventSpecificData&gt;
  </code></pre>
  
  <p>I want to get the value for <code>&lt;Word&gt;</code>, so I pass in <code>/Keyword/Word</code> and set a variable to:</p>
  
  <pre><code>set @value = @xmlPath.value('(/EventSpecificData/@attribute)[1]', 'varchar(max)')
  </code></pre>
  
  <p>However, I don't think @attribute is actually inserting the variables string. Is there another way to do this?</p>