SQL Server showing nvarchar for the variables declared as varchar in the code

AC 1 Reputation point
2020-11-18T00:18:51.863+00:00

I have a typical scenario where in the SQL Server execution plan i can see there is implicit type conversion to nvarchar. Table field has varchar data type and in the code also it is declared as varchar data type as well. It is QL Server 2017 RTM CU21 and it Azure VM. Because of this implicit conversion to nvarchar index is not being used and is causing performance issues such as locking and blocking. I have not seen like this before. The code is written in MyBatis framework. I am kind a lost why it is happening like that.

I appreciate any help and guidance on this typical case.

Thanks in advance.

SQL Server | Other
{count} votes

7 answers

Sort by: Most helpful
  1. AC 1 Reputation point
    2020-11-19T02:03:59.237+00:00

    Thanks Dan. Will run a trace and confirm it.


  2. Simon Ye 1 Reputation point
    2021-02-27T01:39:58.063+00:00

    any soluton for this problem?we have same problem with mybatis 3.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.