1

这是第一次在sql server上工作。我在“END”处收到错误,因为“END 附近的语法不正确”。假设如果我删除“限制 20”,它不是播种错误。我该如何解决。我的过程:

ALTER PROCEDURE [dbo].[GettotalApps]
AS 
BEGIN
   SET  XACT_ABORT  ON
   SET  NOCOUNT  ON

   SELECT
       v.appId,
       v.Description,
       (SELECT COUNT(appidorchannelid) 
        FROM ratings r 
        WHERE r.AppIdOrChannelId = v.channelid) AS Channelvotes
   FROM 
       apps v
   WHERE 
       v.ChannelStatusId = 1 
       AND v.IsChannelPrivate = 0
   ORDER BY 
       SubscriberCount DESC 
   limit 20
END
4

1 回答 1

2

SQL Server 没有LIMIT关键字 - 这是 MySQL 特定的、非 ISO/ANSI 标准的扩展。

请改用TOP关键字:

 SELECT TOP (20)
       v.appId,
       v.Description,
       (SELECT COUNT(appidorchannelid) 
        FROM ratings r 
        WHERE r.AppIdOrChannelId = v.channelid) AS Channelvotes
 FROM 
      apps v
于 2013-04-13T07:43:04.043 回答