Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query help

Author  Topic 

SP273
Starting Member

14 Posts

Posted - 2011-03-10 : 10:02:01
Hi,

I have written this simple query:

(
SELECT [LoadID],
[Name],
[Emp_Level]
FROM dbo.Emplmember em
left outer join dbo.HS_Employerchy scp on scp.Child=em.Name
where scp.DataStorage NOT IN ('ShareData')
)

when i run this query it gives me following error:

Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'LoadID'.

when i remove column name loadID query runs fine. I have a column name loadID in my dbo.Emplmember table still it comes up with error. Any clue what might be causing this error?

Thanks!

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-03-10 : 10:19:25
assuming you want LoadID from the Emplmemr table
SELECT	em.[LoadID],
[Name],
[Emp_Level]
FROM dbo.Emplmember em
left outer join
dbo.HS_Employerchy scp
on scp.Child = em.Name
where scp.DataStorage NOT IN ('ShareData')

If you want it from HS_Employerchy. change the part in red to scp.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-10 : 10:46:44
It is always a best practice to qualify column names with table alias if joins are used

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -