I'm new to sqlserver, and i have this error that i was not able to fix:
Msg 245, Level 16, State 1, Procedure info, Line 11 Conversion failed when converting the varchar value 'Steven' to data type int Can you please show me where is the error, and how can i fix it? The code is as follow thank you.
CREATE PROCEDURE info (@id int , @howMuch int OUTPUT) AS select * from emp where empno=@id; select @howMuch =count (*) from emp; declare @name varchar(100) select @name=ename from emp where empno=@id return @name --with return doesn't work!! --select @name with select it works !! --@name as an output parameter it works!! GO -- execute the procedure. It gives me error. DECLARE @num_rows int, @who varchar(100) EXECUTE @who=info 100, @num_rows OUTPUT select @num_rows,@who
I have noticed that: If instead of using "return" I use "print" to visualize the "@name", the procedure works, and i see "@name". It also works well if instead of "return" I put "@name" as an output parameter. It seems that the error is only when using "return" to return @name. Why is this? What i'm missing to understand?