title: Stuff for XML Path Can't concatenate BIT type
body: <p>I have a field that is a bit type that simulates a boolean, but I'm trying to concatenate the field into a string field using <code>STUFF FOR XML PATH</code> and it keeps giving me an error. Here's the Query:</p>
  
  <pre><code>select
      ui.IndivId,
      ui.correctedInFNV,
      ni.firstName,
      ni.prefName,
      ni.lastName,
      ni.suffix,
      ni.alreadyCorrect as nameCorrect,
      ni.updated as nameUpdated,
      ni.updatedDate,
      ni.correctPerson,
      ai.addr1,
      ai.addr2,
      ai.addr3,
      ai.city,
      ai.state,
      ai.zip,
      ai.country,
      ai.alreadycorrect as adcorrect,
      ai.updatedDate,
      ai.updated as adupdated,
      pi.priPhoneType,
      pi.priPhoneNumber,
      pi.updated as phoneupdated,
      pi.updateddate,
      ei.priEmailType,
      ei.priEmailAddress,
      ei.alreadycorrect as emailcorrect,
      ei.updated as emailupdated,
      STUFF((SELECT ','+pos.positionTitle from positionInfo as pos where pos.IndivId=ui.IndivId FOR XML PATH('')),1,1,'') AS POS_TITLE,
      STUFF((SELECT ','+pos.positionId from positionInfo as pos where pos.IndivId=ui.IndivId for XML PATH('')),1,1,'') as POS_ID,
      STUFF((SELECT ','+pos.positionCode from positionInfo as pos where pos.IndivId=ui.IndivId for XML PATH('')),1,1,'') as POS_CODE,
      STUFF((SELECT ','+pos.areaServed from positionInfo as pos where pos.IndivId=ui.IndivId for XML PATH('')),1,1,'') as POS_AREA,
      STUFF((SELECT ','+pos.districtServed from positionInfo as pos where pos.IndivId=ui.IndivId for XML PATH('')),1,1,'') as POS_DIST,
      STUFF((SELECT ','+pos.reason from positionInfo as pos where pos.IndivId=ui.IndivId for XML PATH('')),1,1,'') as POS_REASON,
      STUFF((SELECT ','+pos.currentlyHeld from positionInfo as pos where pos.IndivId=ui.IndivId FOR XML PATH('')),1,1,'') AS POS_HELD
  from 
      updatedInfo as ui
      join nameInfo as ni on ui.IndivId=ni.nameInfoId
      join addressInfo as ai on ui.IndivId=ai.addressInfoId
      join phoneInfo as pi on ui.IndivId=pi.phoneInfoId
      join emailInfo as ei on ui.IndivId=ei.emailInfoId
      JOIN positionInfo AS pos ON ui.IndivId=pos.IndivId
  </code></pre>
  
  <p>When this is run, I get the error</p>
  
  <blockquote>
    <p>Msg 402, Level 16, State 1, Line 36 The data types varchar and bit are
    incompatible in the add operator.</p>
  </blockquote>
  
  <p>It's screaming about the final <code>STUFF</code> statement for <code>pos.currentlyHeld</code>.
  So I try to convert or cast the field to a char type like this:</p>
  
  <p><code>STUFF((SELECT ','+CAST(pos.currentlyHeld AS VARCHAR(1)) FROM positionInfo as pos where pos.IndivId=ui.IndivId FOR XML PATH('')),1,1,'') AS POS_HELD</code></p>
  
  <p>Then it screams at me because of a comma somewhere? Not sure.</p>
  
  <blockquote>
    <p>Msg 245, Level 16, State 1, Line 1 Conversion failed when converting
    the varchar value ',' to data type int.</p>
  </blockquote>
  
  <p>Where is the syntax issue? or is this more data type issues?</p>