while sending request parameter to this stored procedure
i need to insert an department _id ,fy_id, vertical_id , while inserting .Before that i set one temp int variable and then assign it to query
And checking the condition of temp variable if temp variable is 0 then could not only value isto be inserted

ALTER PROCEDURE [dbo].[insert_approved_man_power](
@fy_id INT ,
@department_id INT ,
@approved_man_power INT,
@login_id nchar(10),
@login_dt smalldatetime ,
@vertical_id INT)

AS 
declare @temp  int

set @temp = 0

set @temp = select department_id from approved_man_power where department_id != @department_id  and fy_id != @fy_id and  vertical_id != @vertical_id 

if @temp = 0

BEGIN

INSERT INTO approved_man_power(fy_id,department_id,approved_man_power,login_id,login_dt,vertical_id)
	 VALUES (@fy_id,@department_id ,@approved_man_power,@login_id,@login_dt,@vertical_id) 
END

i am changing your line no 14 and 16

SET @temp = SELECT count(*) FROM approved_man_power WHERE department_id = @department_id  AND fy_id= @fy_id AND  vertical_id = @vertical_id  

IF isnull(@temp,0) = 0

Do not post your probles in code snippet. Post it as Forum Thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.