1

It's first time to work on sql server. i am getting error at "END" as "incorrect syntax near END". suppose if i remove "limit 20", its not sowing error. how can i fix it. my proc:

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
1

1 Answer 1

2

SQL Server doesn't have a LIMIT keyword - that's a MySQL specific, non-ISO/ANSI-standard extension.

Use the TOP keyword instead:

 SELECT TOP (20)
       v.appId,
       v.Description,
       (SELECT COUNT(appidorchannelid) 
        FROM ratings r 
        WHERE r.AppIdOrChannelId = v.channelid) AS Channelvotes
 FROM 
      apps v
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.