2012-04-06 10 views
0

を提供しながら、行全体を削除: reg_num、USER_NAME、phone_num、指定私は、エンティティとテーブルをしただけで一つの入力変数

私はちょうど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 

答えて

0

あなたはdelete文の列を指定しないでください:

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

特定の値だけを削除したい場合、つまりphone_numを削除したいとしますか? –

+0

あなたは一つの値を '削除'することはできません。例えば、それを更新してください。 update nameTable set phone_num = null where reg_num = @reg_num – Macros

0

は、あなただけのテーブル名、列挙された列の必要はありませんを指定する必要があります。

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

すなわち

も参照してください。 http://www.w3schools.com/sql/sql_delete.asp

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 
+0

特定の値だけを削除したい場合、つまりphone_numを削除したいとしますか? –

関連する問題