
-- CONVERT a string to XML then CONVERT it back to NVARCHAR(10)
SELECT CONVERT(NVARCHAR(20), CONVERT(XML, '<b>  </b>', 1), 1)
--  <b>  </b>  -- retain whitespace, no entitization
GO

SELECT CONVERT(NVARCHAR(20), CONVERT(XML, '<b>  </b>', 0), 0)
-- <b/>       -- don't retain whitespace
GO

SELECT CONVERT(NVARCHAR(20), CONVERT(XML, '<b>  </b>', 0), 1)
-- <b/>       -- don't retain whitespace
GO

SELECT CONVERT(NVARCHAR(20), CONVERT(XML, '<b>  </b>', 1), 0)
-- produces <b> &#x20;</b>
GO