• radek.celuch (5/6/2016)


    Variable IS NOT converted to nchar. It is the other way arround. The literal is converted to char and thus the value set to variable is dependent on databse collation

    Actually conversion happens in both directions in the QotD code.

    In the assignment to the variable, the literal is converted to varchar (as demonstrated by your code, or alternatively as is clear from the way implicit conversion is required to operate in order to avoid type violations).

    However, in the call to UNICODE the value of the variable is converted to NVARCHAR so that it can act as an argument for UNICODE, as is clearly required to provide a valid argument to the UNICODE function.

    So there are implicit conversions in both directions, each where the direction used is the one required by the semantics of T-SQL.

    Tom