0

Hi there,
How can I write a stored procedure to select a value from a table and return that value??
I have a table Employee, when I send the email as a parameter to the stored procedure, I should get the employee number (it should return the employee number)
I am trying to execute the stored procedure in C# code.
I wrote a code but not sure about this and it is wrong how can I fix it

CREATE PROCEDURE dbo.getEmpID
	declare @empid int
AS
BEGIN
	/* SET NOCOUNT ON */
	Select @empid From Employee Where Email=@empid
	
END

appriciate if some one could guide me


thankxxxxxxx

3
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by judithSampathwa
0

You don't want to select @empid, you want to select the column in your table that contains the ID. @empid should be set to the email address of the Employee.

0

You don't want to select @empid, you want to select the column in your table that contains the ID. @empid should be set to the email address of the Employee.

no i want the employee number to bereturned, when the email addreee is provided as the input parameter

thanks

0

what momerath was saying is that the way you have it set up right now you will be returning your parameter, not the employee number from your employee table.
it should be something like...

Select empNumber From Employee Where Email=@empid

0

what momerath was saying is that the way you have it set up right now you will be returning your parameter, not the employee number from your employee table.
it should be something like...

Select empNumber From Employee Where Email=@empid

ohh yeah it should b @email,
if so is the query correct???

thanxxxxx

0

select empnumber from employee where email = @email... there should not be an @ in the select.

0

select empnumber from employee where email = @email... there should not be an @ in the select.

ok,
so how do you get the empID from the c# code when executing the stored procedure????

thanxxxxxxxxxx

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.