このコードの実行中に発生したエラーの数があります:
@emp の構文が正しくない - 11 行目
スカラー変数 @handle を宣言する必要があります -- 19 行目 スカラー変数 @handle を
宣言する必要があります -- 32 行目
/*Delete the selected list */
use database
/* create procedure with in scehema */
Create procedure schema.Proc_delete_emp
@emp varchar(50) =0
@displayname nvarchar(50)=0
@userId int =0
AS
BEGIN
/* Internal variables */
DECLARE @Handle INT
@emp =select emp from dbo.emp_list
/*definition of emp_list table (userid,emp)*/
/* Insert the list into audit table */
INSERT INTO schema.tbl_audit(@emp, @displayname, @UserID)
VALUES('emp', CURRENT_USER, system_user)
/* Get Handle */
SELECT @Handle = SCOPE_IDENTITY() -- get handle
Select handle
From schema.tbl_emp_list
Where delete_handle = 0 and card_type = 'n' --/** Normal**/
/* delete the inserted list from the original table */
Delete from dbo.emp_list
Where pan in (select card_ID from schema.tbl_emp_list )
/* Update table inside the schema */
Update schema.tbl_emp_list
Set delete_handle = @handle
Where delete_handle=0 and card_type ='n';
end