When I write the data access portion like this FROM myMessage m2INNER JOIN Message_Code M1 ON m2.Message_Cd = M1.Message_Cd AND m2.Message_Language_Cd = M1.Message_Language_Cd LEFT JOIN User_Message UM ON m2.Group_Trans_Id = UM.Group_Trans_Id WHERE m2.[Business_Key_Id] = @myMessage_Id
it performs a scan on the Primaryif I rewrite to do a derived look up on a col with a unique index it does the seek?I'm confused FROM (SELECT Group_Trans_Id FROM myMessage WHERE [Business_Key_Id] = @myMessage_Id) AS XXXINNER JOIN myMessage m2 ON m2.Group_Trans_Id = XXX.Group_Trans_IdINNER JOIN Message_Code M1 ON m2.Message_Cd = M1.Message_Cd AND m2.Message_Language_Cd = M1.Message_Language_Cd LEFT JOIN User_Message UM ON m2.Group_Trans_Id = UM.Group_Trans_Id-- For whatever reason, this causes a scan and uses the PK Index, instead of IX_myMessage_Business_Key_Id-- for a seek operation. Did the derived table which uses the correct index and does a seek-- WHERE m2.[Business_Key_Id] = @myMessage_Id
Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/