--Table 1CREATE TABLE [dbo].[Indexing2]( [Col1] [int] IDENTITY(1,1) NOT NULL, [Col2] [int] NULL, [Col3] [int] NULL, [Col4] [int] NULL) --IndexesCREATE UNIQUE CLUSTERED INDEX [CX] ON [dbo].[Indexing2] ([Col1])CREATE NONCLUSTERED INDEX [NCX] ON [dbo].[Indexing2] ([Col4])--Table2CREATE TABLE [dbo].[Indexing]( [ID] [int] IDENTITY(1,1) NOT NULL, [Col2] [int] NULL) --IndexesCREATE UNIQUE CLUSTERED INDEX [CX] ON [dbo].[Indexing] ([ID])CREATE NONCLUSTERED INDEX [NCIX] ON [dbo].[Indexing] ([Col2])
select Col4 from Indexing2inner join Indexing on Indexing2.Col4 = Indexing.Col2where Col4 between '200' and '250'select Col4 from Indexing2where exists (select * from Indexing where Indexing.Col2 = Indexing2.Col4)and Col4 between '200' and '250'
We walk in the dark places no others will enterWe stand on the bridge and no one may pass