Problem creating a procedure

  • hello,

    I am new to SQL and trying to create a procedure in SQl Server 2008 R2.

    This is the code that I copy and pasted from the training book.

    CREATE PROCEDURE GET_CD_ARTISTS ( )

    SELECT cd.CD_TITLE, a.ARTIST_NAME

    FROM COMPACT_DISCS cd, ARTIST_CDS ac, ARTISTS a

    WHERE cd.COMPACT_DISC_ID = ac.COMPACT_DISC_ID

    AND ac.ARTIST_ID = a.ARTIST_ID;

    However, I get the error around the brackets in the first line:

    Msg 102, Level 15, State 1, Procedure GET_CD_ARTISTS, Line 1

    Incorrect syntax near ')'.

    Any solution to the problem?

    Thanks.

  • Try dropping the parens.

  • The correct Syntax is

    CREATE PROCEDURE GET_CD_ARTISTS

    AS

    SELECT cd.CD_TITLE, a.ARTIST_NAME

    FROM COMPACT_DISCS cd, ARTIST_CDS ac, ARTISTS a

    WHERE cd.COMPACT_DISC_ID = ac.COMPACT_DISC_ID

    AND ac.ARTIST_ID = a.ARTIST_ID;

    Regards,

    SAN -INDIA

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply