Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get CONVERT_IMPLICIT for same data type?

Tags:

sql-server

Consider this snippet:

CREATE TABLE #Temp ( Name varchar(100) )
GO

DECLARE @Name varchar(100)
SELECT  @Name = '123'

SELECT * FROM #Temp WHERE Name = @Name

When inspecting it's execution plan, I got a CONVERT_IMPLICIT call on @Name variable:

[tempdb].[dbo].[#Temp].[Name]=CONVERT_IMPLICIT(varchar(100),[@Name],0)

Why this happens, as I have same data types?

like image 289
Rubens Farias Avatar asked Sep 18 '26 00:09

Rubens Farias


1 Answers

I see that CONVERT_IMPLICIT when running your script in the context of a database with a different collation than tempdb.

When running from a DB with the same collation it does not appear in the plan.

In some circumstances this can fail with the error

Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict

but I'm not sure of the circumstances when this implicit conversion can't be done.

like image 159
Martin Smith Avatar answered Sep 20 '26 18:09

Martin Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!