For each row in the table SalesRep_Info, i have a column ManagerID. ManagerID is the primary key of the same table having the ManagerID saved for each Sales Rep. So i need to get the FirstName of the Manager as a new column. I am wondering if this is the right way of doing it in sql server 2005 by declaring and setting?!!
Thank you in advance!
declare @RepID int
set @RepID = (Select Manager from SalesRep_Info)
Select *, (Select FirstName from SalesRep_Info where RepID=@RepID) as ManagerFname from SalesRep_Info
You want a join: