Hi,
For the following query the estimated execution plan identifies a missing index
/*
Missing Index Details from SQLQuery20.sql - WCCSQL.TicketorWCC_TEST (sa (107))
The Query Processor estimates that implementing the following index could improve the query cost by 85.2079%.
*/
/*
USE [MyDatabase]
GO
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[VEHICLE] ([ADDRCITY],[ADDRESS])
INCLUDE ([TICKETNUM],[AddrNoCrLf])
GO
*/
I created the index, refreshed the query but it still displayed the missing index. I then added the index as a hint but that hasn't helped either.
The table function used in the query is on another table so the optimizer is not referring to that.
The query is
Declare @Address nvarchar(255)
Declare @Ticket nvarchar(10)
Declare @CityName nvarchar(50)
Declare mycursor cursor for
select v.AddrNoCrLf,v.TICKETNUM from [TicketorWCC_TEST].dbo.vehicle v where ADDRESS is not null and len(ADDRESS) > 5 and ADDRCity is null
OPEN myCursor
FETCH NEXT from myCursor into @Address,@Ticket
WHILE @@FETCH_STATUS = 0
begin
Select @CityName = (select top 1 [CityName] from dbo.fnGetCityName(@Address))
update v1 set ADDRCITY = @CityName from [TicketorWCC_TEST].dbo.Vehicle v1 with (INDEX(ixAddressCityAddress)) where TICKETNUM = @Ticket
FETCH NEXT FROM myCursor into @Address,@Ticket
end
CLOSE myCursor
DEALLOCATE myCursor
It is a very slow query anyway due to the function so anything I can do to improve it is greatly appreciated.
bob_clegg