title: SQL Server convert NULL to empty string in select *
body: <p>I need to execute the following:</p>
  
  <pre><code> SELECT * FROM [MY_TVF](9186)
   FOR XML AUTO, ELEMENTS
  </code></pre>
  
  <p>And replace all <code>NULL</code> values with an empty string <code>''</code> to include them in the XML. I know I can spit out the elements with an <code>xsi:nil="true"</code> attribute by setting <code>ELEMENTS XSINIL</code>, but I don't want that.</p>
  
  <p>I found this question: <a href="https://stackoverflow.com/q/20247063/1313143">Convert NULL to Empty String SQL Server</a>, where the answer says  I can use <code>ISNULL()</code> around my query. I tried it like so:</p>
  
  <pre><code>ISNULL((SELECT * FROM [MY_TVF](9186)),'')
  FOR XML AUTO,ELEMENTS
  </code></pre>
  
  <p>But I can't get it to work. I get the following error:</p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Line 1
    Incorrect syntax near ','.</p>
  </blockquote>
  
  <p>What can I do to simply replace all <code>NULL</code> values with an empty string so they are included in the XML?</p>
  
  <h2>Edit</h2>
  
  <p>There is no way to replace the <code>*</code> by column names. There is a reason we use a TVF, there are about 40 columns and they might change over time. My query is just to select everything and return it as XML.</p>