2

I have a script that I'm trying to run on SQL 2012 that uses the FASTFIRSTROW hint, but that doesn't work in SQL 2012.

SELECT 
    C.*, N.TemplatePath
FROM 
    Content C WITH (UPDLOCK, FASTFIRSTROW),  
    Nav_Menu N WITH (UPDLOCK, FASTFIRSTROW), 
    Nav_Menu Nb WITH (UPDLOCK, FASTFIRSTROW)
  WHERE 

    C.NavMenuID = N.NavMenuID
    AND 
    N.AncestorNavMenuID = Nb.NavMenuID
    AND 
    ISNULL(N.HideFlag,'N') <> 'Y'
    AND 
    ISNULL(Nb.HideFlag,'N') <> 'Y'
    AND 
    C.WorkflowStatusCode = 'P'

How do I replace FASTFIRSTROW with OPTION (first 1)?

4

1 回答 1

1

您应该能够OPTION (FAST n)在 where 子句之后将提示添加到查询的末尾。

SELECT 
    C.*, N.TemplatePath
FROM 
    Content C WITH (UPDLOCK),  
    Nav_Menu N WITH (UPDLOCK), 
    Nav_Menu Nb WITH (UPDLOCK)
  WHERE 

    C.NavMenuID = N.NavMenuID
    AND 
    N.AncestorNavMenuID = Nb.NavMenuID
    AND 
    ISNULL(N.HideFlag,'N') <> 'Y'
    AND 
    ISNULL(Nb.HideFlag,'N') <> 'Y'
    AND 
    C.WorkflowStatusCode = 'P'
OPTION (FAST 1)
于 2013-07-05T23:51:24.240 回答