Solved

The multi-part identifier "CourtesyCars.carreg" could not be bound.

Posted on 2006-07-05
4
313 Views
Last Modified: 2008-03-17
Hi

I have been working on trying to convert this query from Access to SQL Server for the past day and am still having trouble. Im almost there, but am still getting the following error message on the query below:

The multi-part identifier "CourtesyCars.carreg" could not be bound.

I can see why Im getting this, but cant seem to rectify it. Any ideas?

Cheers

SELECT     Repairs.repairs_ID, InsuranceCompanies.insurance_ID, OwnersCar.car_ID, OwnersCar.mobile AS custMobile, Repairs.stage,
                      Repairs.customerInformed, Repairs.finished, Repairs.courtesyCar_ID, Repairs.hirecar, CC_1.in_date, CC_1.out_date,
                      CarManafacturers.Manafacturer + ' ' + CarModels.Model AS Vehicle, OwnersCar.title + ' ' + OwnersCar.OwnerName AS Owner,
                      OwnersCar.CarReg AS Reg, Repairs.JobRefNo AS JobRef, CourtesyCars.carreg AS CC, Repairs.StartDate AS Start,
                      InsuranceCompanies.Name AS Provider, StatusCodes.Description AS Status, Repairs.EstFinishDate AS Finish, Repairs.HitCount AS [Hit count],
                      OwnersCar.claimnumber AS ClaimNo
FROM         Repairs INNER JOIN
                      InsuranceCompanies ON InsuranceCompanies.insurance_ID = Repairs.insurance_ID INNER JOIN
                      CarModels ON CarModels.make_id = Repairs.make_ID INNER JOIN
                      CarManafacturers ON CarManafacturers.Manafacturers_id = CarModels.Manafacturer_id INNER JOIN
                      StatusCodes ON StatusCodes.Status_ID = Repairs.stage INNER JOIN
                      OwnersCar ON OwnersCar.car_ID = Repairs.cars_ID INNER JOIN
                      colours ON OwnersCar.colour_id = colours.colour_id LEFT OUTER JOIN
                          (SELECT     cc.carreg, cch.ccar_history_id, cch.in_date, cch.out_date
                            FROM          CourtesyCars AS cc INNER JOIN
                                                   ccar_history AS cch ON cc.courtesyCar_ID = cch.ccar_id) AS CC_1 ON Repairs.courtesyCar_ID = CC_1.ccar_history_id LEFT OUTER JOIN
                      Operatives ON Repairs.Op_ID = Operatives.Op_Id
WHERE     (1 = 1) AND (Repairs.potential = 0) AND (Repairs.finished = 0) AND (Repairs.StartDate <= GETDATE())
0
Comment
Question by:digital_soul
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 125 total points
ID: 17041335
Hi digital_soul,

SELECT     Repairs.repairs_ID, InsuranceCompanies.insurance_ID, OwnersCar.car_ID, OwnersCar.mobile AS custMobile, Repairs.stage,
                      Repairs.customerInformed, Repairs.finished, Repairs.courtesyCar_ID, Repairs.hirecar, CC_1.in_date, CC_1.out_date,
                      CarManafacturers.Manafacturer + ' ' + CarModels.Model AS Vehicle, OwnersCar.title + ' ' + OwnersCar.OwnerName AS Owner,
                      OwnersCar.CarReg AS Reg, Repairs.JobRefNo AS JobRef, CourtesyCars.carreg AS CC, Repairs.StartDate AS Start,
                      InsuranceCompanies.Name AS Provider, StatusCodes.Description AS Status, Repairs.EstFinishDate AS Finish, Repairs.HitCount AS [Hit count],
                      OwnersCar.claimnumber AS ClaimNo
FROM         Repairs INNER JOIN
                      InsuranceCompanies ON InsuranceCompanies.insurance_ID = Repairs.insurance_ID INNER JOIN
                      CarModels ON CarModels.make_id = Repairs.make_ID INNER JOIN
                      CarManafacturers ON CarManafacturers.Manafacturers_id = CarModels.Manafacturer_id INNER JOIN
                      StatusCodes ON StatusCodes.Status_ID = Repairs.stage INNER JOIN
                      OwnersCar ON OwnersCar.car_ID = Repairs.cars_ID INNER JOIN
                      colours ON OwnersCar.colour_id = colours.colour_id LEFT OUTER JOIN
                          (SELECT     cc.carreg, cch.ccar_history_id, cch.in_date, cch.out_date
                            FROM          CourtesyCars AS cc INNER JOIN
                                                   ccar_history AS cch ON cc.courtesyCar_ID = cch.ccar_id) AS CC_1 ON Repairs.courtesyCar_ID = CC_1.ccar_history_id LEFT OUTER JOIN
                      Operatives ON Repairs.Op_ID = Operatives.Op_Id
WHERE     (1 = 1) AND (Repairs.potential = 0) AND (Repairs.finished = 0) AND (Repairs.StartDate <= GETDATE()) CourtesyCars

You had not aliased the joined pseudo-table

Tim Cottee
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17041353
digital_soul,
> CourtesyCars.carreg  
try by replacing the above with
                     CC_1.carreg
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
t-sql Joining Issue 10 37
Live Storage Vmotion VMs with shared VMDK 10 57
SSIS with VPN COnnection 2 74
T-SQL:  Collapsing 9 23
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question