I'll try and put it another way. It is NOT big-endian! It is no-endian!
The cast makes no assumption about the source data and 'gives' you the bytes
from left to right without otherwise massaging them in any way.
You do not need documentation to support this. This is what you are
observing.
It is the BitConverter class that 'knows' to return the bytes for an int
reversed (big-endian).
> I'll try and put it another way. It is NOT big-endian! It is no-endian!
>
> The cast makes no assumption about the source data and 'gives' you the
> bytes
> from left to right without otherwise massaging them in any way.
The behavior the OP claims to observe is that the cast, not BitConverter, is
reversing the bytes.
> You do not need documentation to support this. This is what you are
> observing.
Here's what the documentation
http://msdn2.microsoft.com/en-us/library/ms187928.aspx says:
SQL Server guarantees that only roundtrip conversions, conversions that
convert a data type from its original data type and back again, will yield
the same values from version to version.
Note:
Do not try to construct binary values and then convert them to a data
type of the numeric data type category. SQL Server does not guarantee that
the result of a decimal or numeric data type conversion to binary will be
the same between versions of SQL Server.
> It is the BitConverter class that 'knows' to return the bytes for an int
> reversed (big-endian).
[quoted text clipped - 43 lines]
>>>> integer hard coded in tsql getting converted to big endian when it
>>>> arrives in a clr function?