Thanks to

‘A’ = N’A’ , will not kill index seek in sqlserver version above 2014 anymore

The advisor show us that we can get different behavior when we use condition , ='20000' or N'20000'

 

CODE

/*+++++++++++++++++*/

set nocount on

go

create table dbo.Data

(

  Id int not null identity(1,1),

  VarcharColumn varchar(10) not null,

  Placeholder char(200) null

  constraint DEF_Data_Placeholder

  default 'The placeholder',

  constraint PK_Data

  primary key clustered(ID)

)

go

 

declare

  @I int

select @I = 0

begin tran

  while @I < 50000

  begin

  insert into dbo.Data(VarcharColumn)

  values(convert(varchar(10),@I))

  select @I += 1

  end

commit

go

create unique nonclustered index IDX_Data_VarcharColumn

on dbo.Data(VarcharColumn)

go

 

/*+++++++++++++++++*/

 

In his article, He means

 

‘A’ = N’A’ , will not kill index seek in sqlserver version above 2014 anymore

 

‘A’ = N’A’ , will not kill index seek in sqlserver version above 2014 anymore

 

 

However, as my site enviroument ,

Microsoft SQL Server 2014 - 12.0.2000.8 (X64) Enterprise Edition (64-bit) on Windows NT 6.1

I get an different result

 

‘A’ = N’A’ , will not kill index seek in sqlserver version above 2014 anymore

 

and

 

‘A’ = N’A’ , will not kill index seek in sqlserver version above 2014 anymore

 

Maybe in sqlserver new version . the SQL engine enhanced.

相关文章:

  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-29
  • 2022-01-09
  • 2022-03-03
  • 2022-01-27
  • 2021-10-12
相关资源
相似解决方案