nchar vs. char conversion performance

  • I was looking at an old SP and noticed it's doing a CONVERT of dissimilar data types;

    select ...........

    FROM leads l

    LEFT JOIN call_detail c ON l.rwa_id = CONVERT(nchar(10), c.rwa_id)

    The odd thing is that l.rwa_id is not nchar, it's char, so the convert is wrong ... possibly a typo? Would there be a performance hit as-is converting c.rwa_id (int) to nchar instead of char ?? I assume I should change it, but am curious about it the way it is.

  • If you're comparing two different data types, char & nchar, then you'll get an implicit convert in the engine which will prevent the use of indexes. So yes, there is a performance hit. If both columns are char, converting to nchar must be a mistake. I'd remove it.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Hi

    By looking at the query i am sure one wold want o have index in the ID column. So if you place any functions that then that would certainly hit performance.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply