如何检查数据是否插入存储过程中

时间:2011-02-12 20:14:51

标签: c# .net sql-server-2005

我创建了一个存储过程来插入员工详细信息。如果此查询以表单形式执行,则不会返回任何值。

create PROCEDURE  [dbo].[employee_mst_insertvalues]
@e_firstname varchar(100),
@e_middlename varchar(100),
@e_lastname varchar(100),
@e_address varchar(1000),
@e_phoneno varchar(15),
@mobileno varchar(15),
@UploadPhoto image

AS
declare @employee_id int
BEGIN
    SET @employee_id=(select max(Employee_id) from mstEmployee)
    if @employee_id is null
    BEGIN
        set @employee_id=1
END
    else
BEGIN
        set @employee_id=@employee_id+1
END
insert into mstEmployee (Employee_id,E_FirstName,E_MiddleName,E_LastName,E_Address,E_PhoneNo,E_MobileNo,UploadPhoto) 
values(@employee_id,@e_firstname,@e_middlename,@e_lastname,@e_address,@e_phoneno,@mobileno,@UploadPhoto)
END

如何返回整数值以检查是否插入了数据。

1 个答案:

答案 0 :(得分:4)

SELECT @@ROWCOUNT将为您提供insert语句影响的行数。