Click here to Skip to main content
15,897,166 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
ALTER procedure [dbo].[GetSubmitDetails]
(
@cust_id int ,
@name varchar (50),
@state Varchar (50),
@s_amount varchar (50),
@sales_id int,
@select out

)

AS
declare @count int
set @count = (SELECT count(*) FROM customer inner join
sales
on customer.cust_id=sales.cust_id
WHERE customer.cust_id = @cust_id
and sales.sales_id=@sales_id)
if(@count>0)
BEGIN

SELECT 'This record already exists!'
END
ELSE

BEGIN


SELECT 'Record Added'
Insert into test.dbo.[customer](cust_id,name,[state]) values (@cust_id,@name,@state)

Insert into test.dbo.[sales](cust_id,sales_id,s_amount) values (@cust_id,@sales_id,@s_amount)
END
Posted
Comments
Pankit Patel 20-May-15 1:42am    
you can use ExecuteReader() for run query in code so this function will give you some messages or some values.

1 solution

Create One new Stored Procedure and write exec code inside this procedure, you will get the message of that previous procedure and then you proceed your code.
SQL
create procedure GetReturnValue
as
begin
declare @result as varchar(50)
exec @result=[dbo].[GetSubmitDetails] @cust_id,@name,@state,@s_amount,@sales_id,@selectout 
end
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900