Skip to main content
1 of 5
Matej
  • 107
  • 6

Sql server changes execution plan

I have SQL code that is executing slowenter image description here

DECLARE @ccode varchar(500) SET @ccode = '%NIP%'

SELECT [CVN_UID] FROM [Klasje].[dbo].[VERSION_CATEGORY_XREFS] WHERE DESCRIPTOR_TEXT LIKE @ccode

Why sql server uses Nested loops?

This code is working fine, it uses only index scan: SELECT [CVN_UID] FROM [Klasje].[dbo].[VERSION_CATEGORY_XREFS] WHERE DESCRIPTOR_TEXT LIKE '%NIP%'

Thank you!

Matej
  • 107
  • 6