Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ALTER PROCEDURE [dbo].[avoidduplicate]

@username varchar(20),

@pword nvarchar(20),

@empname varchar(20),

@email nvarchar(50),

@designation varchar(20),

@reportto varchar(20),

@Result varchar(50) output

as
if exists(Select username from testduplicate where username = @Username)
begin
set @Result = 'Already there'
return
end

insert into testduplicate(username,pword,empname,email,designation,reportto)values(@username,@pword,@empname,@email,@designation, @reportto )
set @Result= 'Success'


if im inserting values below error is coming.

ERROR:
ASM
Msg 201, Level 16, State 4, Procedure avoidduplicate, Line 0
Procedure or function 'avoidduplicate' expects parameter '@Result', which was not supplied.
Posted
Comments
[no name] 30-Sep-14 8:03am    
It looks like you forgot to add this Parameter while using the SP....?
thangaraj kathiravan 30-Sep-14 8:11am    
Which parameter?
[no name] 30-Sep-14 8:12am    
@Result like mentioned in the error message...
thangaraj kathiravan 30-Sep-14 8:16am    
i added as output parameter.. i am not getting clearly.What u r saying..please if u know solution share with me
Richard Deeming 30-Sep-14 8:48am    
The problem is not with the stored procedure, but the code which is calling the stored procedure. You'll need to post that code before anyone can help you.

1 solution

Seems you have not correctly written your SP, try this way.

SQL
ALTER PROCEDURE [dbo].[avoidduplicate]
@username varchar(20),
@pword nvarchar(20),
@empname varchar(20),
@email nvarchar(50),
@designation varchar(20),
@reportto varchar(20),
@Result varchar(50) output
as
BEGIN
    if exists(Select username from testduplicate where username = @Username)
    begin
        set @Result = 'Already there'
        return
    end
     
    insert into testduplicate(username,pword,empname,email,designation,reportto)values(@username,@pword,@empname,@email,@designation, @reportto )
    set @Result= 'Success'
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