XML is a binary data type so it has to de-serialized into a string before it can be cast to a numeric type.
Works because SQL Server XML data types support fragments:
SELECT CAST('1' AS XML)
Does not work *
SELECT CAST(CAST('1' AS XML) AS INT)
Works:
SELECT CAST(CAST(CAST('1' AS XML) AS VARCHAR(100)) AS INT)
* See "Implicit Conversions" section for map of supported implicit and explicit conversions http://msdn.microsoft.com/en-us/library/ms187928.aspx
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato