There is no converssion occuring in reallity. What you see is an artifact of Profiler/Trace having to somehow represent the TDS RPC call as a T-SQL batch you can copy paste and execute in SSMS. The real text executed is just insert into XmlTable (dat) values(@data)
and @data
type/value comes from the ParamData
portion of the request. As with any wire protocol, serialization and encoding has to occur in the client and decoding and deserialization has to occur at the server. As a side note, there is no call to sp_execute_sql
either, that is again an artifact of how Profiler/Trace displays an RPC call.
this code is used in high-load scenario and additional convertation makes it slower
That is speculation. You should base performance analysis on measurements and observations.