IN CORRECT SYNTEX

  • ALTER TABLE TRIPS

    RENAME COLUMN CODE TO AREA;

    I receive this error "INCORRECT SYNTAX NEAR RENAME" RENAME HAS A RED LINE UNDER IT, I AM USING SQL EXPRESS 2008.

    THANKS

  • Try:

    EXEC sp_rename 'Trips.Code', 'Area', 'COLUMN'

  • UPDATE TRP_STATS

    SET TRIP_ID = TRIP,

    FROM TRP_STATS JOIN TRP_DETAILS

    ON TRP_STATS.TRP = TRP_DETAILS.TRP;

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'FROM'.

    I get these error about all the time what am I doing worng?

    Thanks

  • lonhanner (12/29/2012)


    UPDATE TRP_STATS

    SET TRIP_ID = TRIP,

    FROM TRP_STATS JOIN TRP_DETAILS

    ON TRP_STATS.TRP = TRP_DETAILS.TRP;

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'FROM'.

    I get these error about all the time what am I doing worng?

    Thanks

    Review your aliasing.

    Update TRPS

    set TRIP_ID = TRPD.TRIP_ID

    from TRP_STATS TRPS

    INNER JOIN TRP_DETAILS TRPD on TRPS.TRP = TRPD.TRP

    Assuming you want to update stats with the TRIP_ID from TRP_DETAILS

  • lonhanner (12/29/2012)


    UPDATE TRP_STATS

    SET TRIP_ID = TRIP[font="Arial Black"], <----<<<< MUST LOOK EYE![/font] 😛

    FROM TRP_STATS JOIN TRP_DETAILS

    ON TRP_STATS.TRP = TRP_DETAILS.TRP;

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'FROM'.

    I get these error about all the time what am I doing worng?

    Thanks

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • and that's what I get for reading too quickly.

  • JeffRush (12/29/2012)


    and that's what I get for reading too quickly.

    Actually, the OP should look your post over again, and again, and again. Too many people make the mistake of not aliasing properly. Your post is a healthy reminder. Well done.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanks.

    All the aliasing in the world doesn't save you from an errant comma though. 🙂

Viewing 8 posts - 1 through 7 (of 7 total)

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