Click here to Skip to main content
15,896,397 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,

I wrote storedprocedure with inner join ..when i execute sp and passed ID...its showing all the details rather then showing the details of the employee for whom i passed ID


Thank you
Posted
Updated 8-Apr-15 23:09pm
v2
Comments
Magesh M N 9-Apr-15 5:14am    
If you describe your question with the sql query, then that will be helpful to find the errors
Member 11148509 9-Apr-15 5:35am    
select FirstName,LastName,UserType,
Salary,Date
From Employee Emp
inner join EmployeeDetails empdetails
on Emp.EmployeeID=EmployeeDetails.EmployeeID
Member 11148509 9-Apr-15 7:52am    
Thank u all:-)small mistake
Suvendu Shekhar Giri 17-Apr-15 6:10am    
Mark answer(s) as marked which helped you so that others can also find the answer useful :)

May be you have missed to put the filter using `WHERE`
Try this
SQL
create proc [dbo].[YourSpName]
(
   @EmployeeId int
)
as
begin
   select FirstName,LastName,UserType,Salary,Date
   From Employee Emp
   inner join EmployeeDetails empdetails on Emp.EmployeeID=EmployeeDetails.EmployeeID
   where Emp.EmployeeID=@EmployeeId
end

Hope, it helps :)
 
Share this answer
 
v2
Add a WHERE clause to your query:
SQL
SELECT FirstName,LastName,UserType,	
Salary,Date	
FROM Employee Emp
INNER JOIN EmployeeDetails empdetails
ON Emp.EmployeeID=EmployeeDetails.EmployeeID
WHERE Emp.EmployeeID=@IDValueIwantToFindAndPassedAsAParameter
 
Share this answer
 
SELECT FirstName,LastName,UserType,
Salary,Date
FROM Employee Emp
INNER JOIN EmployeeDetails empdetails
ON Emp.EmployeeID=EmployeeDetails.EmployeeID
WHERE Emp.EmployeeID='emp123'
 
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