incorrect syntax near the keyword 'tran'

Posted on 2009-04-18
Last Modified: 2012-06-27
To Whom it May Concern:

I am a student near the final exams. I am trying to write code to insert a reservation for two tables in a restaurant. I can't solve this error message.

The database Resaurant_06 is a fictitious database.  See the attatchment please.

Thanks, Frances123

Question by:frances123
    LVL 30

    Expert Comment

    Its probably this bit:
    rollback tran spCreateReservation
    try using this instead:
    rollback tran
    It should tell you what line the error occurs - what line is it?
    Also you are usually better off using SCOPE_IDENTITY() rather than @@IDENTITY
    LVL 1

    Accepted Solution

    Hi Frances123,

    the problem is the 2 places where you have this line "rollback tran spCreateReservation"

    The line "rollback tran spCreateReservation" tells that a transaction named spCreateReservation should be rollback but you don't have a transaction named spCreateReservation (That is the name of the sproc)

    In you case just change the 2 lines to rollback tran or give the transaction a name



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
    Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now