Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2016
    Posts
    5

    Unanswered: HELP PLS :( Incorrect syntax near the keyword 'AS'.

    CREATE PROCEDURE groupView
    @member1 int = 2,
    @member2 int = 3,
    AS'
    BEGIN
    SELECT g.Name
    FROM grupo g, grupoMembers gm, Member mr
    WHERE (mr.MemberID=@member1 AND mr.MemberID=@member2) AND (mr.MemberID=gm.MemberID AND gm.GroupID=g.GroupID);
    'END
    GO


    I created this procedure and gives me an error that seems simple but I can not solve.

    Could you help me ??

    TY

  2. #2
    Join Date
    Mar 2016
    Posts
    5

    Thread: Incorrect syntax near the keyword 'AS', need a little help T.T

    Hi.
    I have a small syntax error near the AS.
    Dont know what symbol which is used.
    I tried these symbols:

    " " ' ' { }

    But none works.
    Anyone knows the correct symbolto use ??
    Thank U very much in advance for the interest and help forum.

    CODE
    ----------------------------------
    CREATE PROCEDURE groupView
    @member1 int = 2,
    @member2 int = 3,
    AS'
    BEGIN
    SELECT g.Name
    FROM grupo g, grupoMembers gm, Member mr
    WHERE (mr.MemberID=@member1 AND mr.MemberID=@member2) AND (mr.MemberID=gm.MemberID AND gm.GroupID=g.GroupID);
    'END
    GO

    ERROR MSG
    -------------------------------
    Msg 156, Level 15, State 1, Procedure groupView.
    Incorrect syntax near the keyword 'AS'.

    Thanks so much a lot

  3. #3
    Join Date
    Mar 2016
    Posts
    5

    Need a litle help for procedure (Incorrect syntax near the keyword 'AS'.) :(

    Hi.
    I have a small syntax error near the AS.
    Dont know what symbol which is used.
    I tried these symbols:

    " " ' ' { }

    But none works.
    Anyone knows the correct symbolto use ??
    Thank U very much in advance for the interest and help forum.

    CODE
    ----------------------------------
    CREATE PROCEDURE groupView
    @member1 int = 2,
    @member2 int = 3,
    AS'
    BEGIN
    SELECT g.Name
    FROM grupo g, grupoMembers gm, Member mr
    WHERE (mr.MemberID=@member1 AND mr.MemberID=@member2) AND (mr.MemberID=gm.MemberID AND gm.GroupID=g.GroupID);
    'END
    GO

    ERROR MSG
    -------------------------------
    Msg 156, Level 15, State 1, Procedure groupView.
    Incorrect syntax near the keyword 'AS'.

    Thanks so much a lot

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    You don't need any delimiter, the syntax ought to be:
    Code:
    CREATE PROCEDURE groupView
       @member1 int = 2,
       @member2 int = 3,
    AS
    BEGIN 
       SELECT g.Name
          FROM grupo g
    ,        grupoMembers gm
    ,        Member mr
          WHERE (mr.MemberID=@member1
             AND mr.MemberID=@member2)
             AND (mr.MemberID=gm.MemberID
             AND gm.GroupID=g.GroupID);
    END
    GO
    Because the conditions in your WHERE clause are all joined by the AND predicate, you don't need any parentheses. They won't hurt anything, but they don't help either.

    Listing the tables in a comma separated list was the accepted standard through SQL-89, but it has been deprecated in favor of the JOIN operators for well over 20 years. It takes a bit of time to learn to use INNER JOIN, LEFT JOIN, etc. but there are many benefits to using them... It is definitely worth your time to check them out!

    Good luck, and feel free to ask more questions as they arise!

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •