如何编写存储过程以获取最佳记录

时间:2017-11-30 16:45:00

标签: sql-server tsql

如何编写SQL存储过程以从存储过程中获取前n个记录?

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    Provider = new CookieAuthenticationProvider
    {
        // Enables the application to validate the security stamp when the user logs in.
        // This is a security feature which is used when you change a password or add an external login to your account.  
        OnValidateIdentity = validate

    }
});  

我收到了一个错误:

  

'@Sum'附近的语法不正确

1 个答案:

答案 0 :(得分:4)

根据错误,看起来您正在使用SQL Server。

您需要将@Sum括在括号中:

SELECT TOP (@Sum) * 
FROM Customer