我正在创建此表,但我遇到了第一个过程的问题(sp_joseview)
+-----------+----------+----------------+--------+--------+
| vehicleID | peopleID | makeModel | regNo | colour |
+-----------+----------+----------------+--------+--------+
| 1 | 1 | Bugatti Veyron | 12345 | White |
| 2 | 2 | Porsche 911 | 67891 | Black |
+-----------+----------+----------------+--------+--------+
第一个过程显示语法错误,但我无法弄清楚该错误可能是什么。
答案 0 :(得分:9)
错误是不言自明的 - 您不能发出CREATE PROCEDURE
语句,除非它是批处理中唯一的语句。
在SSMS中,GO
关键字将语句拆分为单独的批处理,因此您需要在CREATE PROCEDURE
之前的语句后添加一个:
create table josecustomer(
name varchar(50),
address varchar(300),
ssnid int,
balance bigint,
accountnumber bigint
)
insert into josecustomer values('Aman','Canada',10000,5000,100000000)
insert into josecustomer values('Shubham','USA',10001,6000,200000000)
insert into josecustomer values('Himanshu','Australia',10002,2000,300000000)
insert into josecustomer values('Jose','India',10003,3000,400000000)
insert into josecustomer values('Albert','Brazil',10004,4000,500000000)
insert into josecustomer values('Peterson','Germany',10005,7000,600000000)
insert into josecustomer values('Adam','Honkong',10006,8000,700000000)
insert into josecustomer values('William','Paris',10007,9000,800000000)
select * from josecustomer
Go --Add a Go here
create proc sp_joseview
as begin
select * from josecustomer
end
go
create proc sp_updatejose
(@accountno bigint,@newbalance bigint)
as begin
update josecustomer
set balance=@newbalance
where accountnumber=@accountno
end
go
答案 1 :(得分:4)
关键字GO
在单个脚本中分隔批次。该错误表示CREATE PROCEDURE
必须是批处理中的“唯一”语句,因此您可能会错过某个GO
以上的CREATE PROCEDURE
。
现在看看你的剧本,它分为4个广阔的领域
很明显,你错过了一个介于2.和3之间的go
。