0

我有一个包含实体的表:reg_num、user_name、phone_num、designation

我想编写存储过程,只需输入 reg_num 值即可删除一行的全部数据。

create proc del @reg_num nchar(10)
as
delete reg_num, user_name, phone_num, designation from nameTable 
where reg_num = @reg_num
4

3 回答 3

0

您没有为删除语句指定列:

create proc del @reg_num nchar(10)
as
delete from nameTable 
where reg_num = @reg_num
于 2012-04-06T14:59:29.127 回答
0

您只需要指定表名,不需要列出的列。

IE

create proc del @reg_num nchar(10)
as
delete from nameTable 
where reg_num = @reg_num

另见: http ://www.w3schools.com/sql/sql_delete.asp

于 2012-04-06T15:00:33.550 回答
0

删除时,您必须遵循如下语法:

declare @regNum int
set @regnum = 1

delete from [table] where regnum = @regnum

在存储过程中,您需要这样做:

create procedure test (@regnum int) as 
begin
delete from [table] where regnum = @regnum
end
于 2012-04-06T15:01:10.127 回答