1

The entirety of my code is:

BEGIN TRAN --SACTION
SELECT 1
COMMIT --TRAN

with any combination of tran, transaction or neither it always returns error:

Incorrect syntax near the keyword 'BEGIN'.

I'm using Microsoft SQL Server 7.0. This is a corporate system, a legacy. I can't update it from my own accord.

The code does nothing useful but demonstrates the problem. commit or commit transaction yields the same error. No mimic, I wrote the code myself.

Trying BEGIN TRAN SELECT 1 COMMIT TRAN also gives the same error.

Select 1 runs OK. Begin, Begin Tran or Begin Transaction yield error.

I was pondering if someone could have altered the system catalogs so that the reserved word BEGIN was replaced by another word. In this case, how would I query for the new equivalent?

2
  • 1
    Strictly speaking, COMMIT is a shorthand for COMMIT WORK, but for all I know that means the same as COMMIT TRANSACTION. The latter accepts an optional name, the former doesn't – that seems to be the only the difference between the two. Both variations are (were) supported by SQL Server 7, according to this.
    – Andriy M
    Nov 12, 2015 at 20:10
  • 2
    The link, which is no longer working, was referencing an online version of book Sams Teach Yourself Microsoft SQL Server 7 in 21 Days, specifically section Transactions of chapter Day 16. Programming SQL Server 7.0. I can't find any other online versions of it and the Wayback Machine fails me too. (It lets you reach the chapter header page but not the section where COMMIT WORK is mentioned.)
    – Andriy M
    Oct 13, 2016 at 11:31

0

Your Answer

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

Browse other questions tagged or ask your own question.