SQL Server Performance

stored prod syntax error

Discussion in 'General DBA Questions' started by melon.melon, Jun 18, 2009.

  1. melon.melon New Member

    HelloIf the Delete successful, it will insert into t1Deleted the row from t1 a.If the Delete fails, it will insert into tbLog. stored prod syntax problem: incorrect syntax near 'Delete Failed'

    incorrect syntax near 'RAISEERROR'
    tbLog has ErrorID, ErrorType, Msg, ErrorDate
    BEGIN TRANSACTION
    Delete a from t1 a left join t2 b on b.no=a.no
    left join t3 c on c.no=a.no where a.no=@no
    and b.no is null and c.no is null
    IF @@ERROR=0
    BEGIN
    Insert into t1Deleted (no,Size,Owner,Users)
    values
    (@no,@size,@owner,@user);
    IF @@ERROR=0
    BEGIN
    COMMIT TRANSACTION
    END
    ELSE
    BEGIN
    ROLLBACK TRANSACTION
    RAISEERROR('Delete Failed',1,1)
    Insert into tbLog (ErrorType,Msg)
    values
    ('Delete Failure','Deletion of Vessel Failed');
    IF @@ERROR<>0
    BEGIN
    RAISEERROR('Delete Failed',1,1)
    END
    END
    END

  2. Sandy New Member

    Melon,
    Change RAISEERROR to RAISERROR.
    Hope it will make you smily...[:D].
    Thank you,
    Sandy.
  3. melon.melon New Member

    Thanks Sandy!
  4. Sandy New Member

    My pleasure Melon,
    PS: I knows it but you can also use sqlprompt or sql server 2008 to check this type of syntax error too.
    Thank you,
    Sandy.

Share This Page