Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

The multi-part identifier “dbo.Employee Master Table Data.Employee Number” could not be bound Expand / Collapse
Author
Message
Posted Wednesday, May 27, 2009 4:54 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 28, 2009 2:02 AM
Points: 2, Visits: 7
I get an error when running the below script - The multi-part identifier “dbo.Employee Master Table Data.Employee Number” could not be bound.

Any ideas anyone?

SELECT TOP (100) PERCENT dbo.Employees.ESNumber, [Employee Number] AS EmployeeID_SH, Title AS Title_SH, [First Name] AS Firstname_SH,
Surname AS Surname_SH, [Home E-Mail] AS [Payslip_E-Mail]
FROM HRSELECTDB.selecthr.dbo.[Employee Master Table Data] AS [Employee Master Table Data_1] INNER JOIN
dbo.Employees ON dbo.[Employees Master Table Data].[Employee Number] = dbo.Employees.EmployeeID_SH
ORDER BY EmployeeID_SH

Regards,
Gary
Post #723951
Posted Wednesday, May 27, 2009 5:10 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, October 21, 2013 12:32 AM
Points: 2,556, Visits: 2,593
The problem is with the table qualifier used in the ON Clause for column "Employee Number".

.....
FROM HRSELECTDB.selecthr.dbo.[Employee Master Table Data] AS [Employee Master Table Data_1] INNER JOIN
dbo.Employees ON dbo.[Employees Master Table Data].[Employee Number] = dbo.Employees.EmployeeID_SH
ORDER BY EmployeeID_SH

It should read as
...
dbo.Employees ON [Employees Master Table Data_1].[Employee Number] = dbo.Employees.EmployeeID_SH

And also, as a standard practice, I suggest you to add alias to all tables, keep aliases short & always qualify columns.


--Ramesh

Post #723962
Posted Wednesday, May 27, 2009 6:01 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 28, 2009 2:02 AM
Points: 2, Visits: 7
Excellent, thank you so much

I take on board you comment too!

Thanks,
G
Post #723989
Posted Wednesday, May 27, 2009 6:08 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, October 09, 2013 5:08 AM
Points: 1,127, Visits: 603
Another thing I would suggest is to minimize the use of special characters in database and object names. Instance names you can't always avoid having special characters (\ for example). But in an existing database you have to deal with it of course.

Ronald Hensbergen

Help us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/
-------------------------------------------------------------------------
2+2=5 for significant large values of 2
Post #723993
Posted Wednesday, May 27, 2009 9:54 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 6:05 PM
Points: 22,530, Visits: 30,307
Hopefully I did it correctly for your databases and tables, but this is how I would have written and formatted your code. I am curious how you are using this query. The reason I am asking is due to the presence of the SELECT TOP (100) PERCENT at the beginning and the ORDER BY at the end.

SELECT TOP (100) PERCENT
Emp.ESNumber,
EmpMasterData.[Employee Number] AS EmployeeIDSH,
EmpMasterData.Title AS TitleSH,
EmpMasterData.[First Name] AS FirstnameSH,
EmpMasterData.Surname AS SurnameSH,
EmpMasterData.[Home E-Mail] AS PayslipEMail
FROM
HRSELECTDB.selecthr.dbo.[Employee Master Table Data] AS EmpMasterData
INNER JOIN dbo.Employees AS Emp
ON EmpMasterData.[Employee Number] = Emp.EmployeeID_SH
ORDER BY
EmployeeIDSH




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #724774
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse