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

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.

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

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

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

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

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

I have not used C#, sorry, i can't help you there. i use asp.

I have not used C#, sorry, i can't help you there. i use asp.

that is fnie how do u can in asp????

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.