table:employee
EID ENAME MID(manager ids)
101 rama null
102 sita 101
103 siva 101
104 ganesh 103
. . .
. . .
for 103 ID the manager ID is 101(RAMA) and for 104 manager
is SIVA
if i give employee id (EID) you have to tell the manager for
that EID write query?
eample:if i give 102 .The query output should be manager for
102 ID that it should print RAMA as output
Answer Posted / saravanan p
Declare @eid int
Set @eid=2
select 'The manager for employee id '+convert(varchar
(50),e2.eid)+' is '+e1.ename from emp e1,emp e2
where e1.eid=e2.mid and e2.eid=@eid
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Tell me extended events in sql server 2008?
Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.
What is indexing and its types?
What is change data capture (cdc) in sql server 2008?
Explain important index characteristics?
What is indexing in sql server with example?
What is full outer join in sql server joins?
What is the command used to check locks in microsoft sql server?
What is the difference between lock, block and deadlock? : sql server database administration
Ms sql server index?
What is the boxing and unboxing concept in .net?
Does partitioning help performance?
Which data type columns are the best candidates for full-text indexing?
‘Order by’ is not allowed in a view how can you sort information from a view?
What are sql azure firewall rules?