执行此代码时发生了许多错误:
@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