Select top(20) sno,ecode,name,mobile_no,department,doj,ctc
from charbi..mst_emp_master(nolock)a
inner join charbi..new_emp_salary_master(nolock)b
on a.ecode=b.ecode
where status='Y'
order by doj desc
i m getting error as
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'ecode'.
pls let me know what im doing wrong.
Getting error: Ambiguous column name 'ecode'
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Blocked AccountRank #403 · 6.2K reputationPosted Dec 31, 2012, 6:06 PM EST
Both the table containing ecode column, so you have to mention in your query, from which table you need values from ecode column.
So removing this error either use a.ecode or b.ecode
Select top(20) sno,a.ecode,name,mobile_no,department,doj,ctc
from charbi..mst_emp_master(nolock)a
inner join charbi..new_emp_salary_master(nolock)b
on a.ecode=b.ecode
where status='Y'
order by doj desc
Pranjal Mishra58 reputationPosted Jan 1, 2013, 5:31 AM EST