Hi everyone, do you know why this chunk of code
SerialNoSummary.SETCURRENTKEY("Patient Code","Property No.","Property Type");
IF SerialNoSummary.FINDSET THEN BEGIN
//do some stuff, No db reads/writes involed...
UNTIL SerialNoSummary.NEXT = 0;
generates this query?
SELECT * FROM "mydb"."dbo"."mycompany$Serial No_ Summary" WITH (READUNCOMMITTED) WHERE (("Patient Code"=@P1))
ORDER BY "Item No_","Last Source Code","Last Source Type","Code"
OPTION (OPTIMIZE FOR UNKNOWN)
if i unmaintain key
Item No.,Last Source Code,Last Source Type,Code
in the table, the same code chooses the right key, which is
Patient Code,Property No.,Property Type
which is obviously enabled and maintained.
Moreover, there are no sumindexes fields that make sql choose another key.
The sqlindex property has been set on any key.
The piece of code is in a RTC report; version NAV 2009R2 build 32275
"Never memorize what you can easily find in a book".....Or MibusoMy Blog