title: How to create dynamic sql statment based on single XML parameter
body: <p>i need to create a dynamic SQL statement that selects fields based on an XML parameter.</p>
  
  <p>Say i have a stored proc with 1 param - [@FIELDS XML] that contains field names. eg...</p>
  
  <p>Field 1 = Name</p>
  
  <p>Field 2 = Address etc...</p>
  
  <p>..in reality there would be up to 50 fields and i only want to report on the ones in the XML parameter.</p>
  
  <p>how can i make a simple statement like this work..</p>
  
  <pre><code>select
    xmlParam1,
    xmlParam2,
    ...
    xmlParamN
  from TABLE
  </code></pre>
  
  <p>etc...</p>
  
  <p>NB: the data is coming from a string array in c#.</p>
  
  <p>Thanks!</p>