SQL Server')'附近的语法不正确 [英] SQL Server incorrect syntax near ')'

查看:183
本文介绍了SQL Server')'附近的语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:


Msg 102,级别15,状态1,过程Add_Student,第6行

')'附近的语法不正确。

Msg 102, Level 15, State 1, Procedure Add_Student, Line 6
Incorrect syntax near ')'.

在尝试运行此SQL查询时:

when trying to run this SQL query:

CREATE proc [Add_Student](
    @stud_id varchar(5),
    @fname varchar(25),
    @lname varchar(25),
    @balance decimal = 0
)       
AS
BEGIN
    BEGIN TRANSACTION
        INSERT INTO MyStudent(Student_ID, Fname, Lname, Acct_Bal)
        VAULES (@stud_id, @fname, @lname, @balance)

        IF @@ERROR <> 0
        BEGIN
            Rollback Transaction
            Raiserror ('Unable to insert record.',16,1)
            return -1
        END
        ELSE
        BEGIN
            Commit Transaction
            Print 'Record Added Successfully!'
        END
    END


推荐答案

您在)附近有错字:

INSERT INTO MyStudent(Student_ID, Fname, Lname, Acct_Bal)
VAULES (@stud_id, @fname, @lname, @balance)

应为 VALUES而不是 VAULES。

It should be "VALUES" not "VAULES".

这篇关于SQL Server')'附近的语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆