这是第一次使用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
答案 0 :(得分: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