• danielfountain (2/17/2012)


    Hugo Kornelis (2/17/2012)


    Nice, easy question - though I'm sad that as of this time, 8% of respondends got it wrong.

    There is an error in the explanation, though. You can not avoid the implicit conversion. You can only change it. Making the parameter varchar(100) instead of nvarchar(20) means that now the implicit conversion from an implicit conversion from varchar to nvvarchar during the scan, to an implicit conversion from nvarchar to varchar during the procedure call.

    Or you can leave the parameter as is and add an explicit cast in the query. Again, not avoiding the conversion, but making it explicit.

    Surely that is assuming that the procedure is passed an nvarchar at the moment. Surely it could be being passed a varchar that is converted to an nvarchar for the proc and back to a varchar for the seek?

    Perhaps the above is the case - in which case you are getting rid of all conversions.

    True.

    In that case, the best way to improve performance is to fire the nincompoop developer who came up with the crazy idea of making the parameter nvarchar. :hehe:


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/