Shyam s
Shyam s

Reputation: 779

how to check data is inserted or not in stored procedure

i have creating a stored procedure to insert employee details.if this query is executed in form it will not return any value.

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

how can i return a integer value to check whether data is inserted or not.

Upvotes: 3

Views: 874

Answers (1)

Itay Karo
Itay Karo

Reputation: 18286

SELECT @@ROWCOUNT will give you the number of rows affected by the insert statement.

Upvotes: 4

Related Questions