mercredi 13 janvier 2016

SQL-Server 2005: multi-part identifier could not be bound

I'm working with SQL Server 2005, I'm new to SQL so bear with me.

The following aliased SQL query is giving me the following error:

The multi-part identifier "EquipmentDescription.DESCRIPTION" could not be bound.

SQL:

WITH somerows as 
(
    SELECT 
        Mastertable.ID, Mastertable.foo1, Mastertable.foo2, 
        Mastertable.foo3, EquipmentDescription.DESCRIPTION,
        ROW_NUMBER() OVER (ORDER BY Mastertable.ID) AS SeqValue 
    FROM 
        EquipmentDescription 
    LEFT JOIN 
        MasterTable ON EquipmentDescription.foo1 = MasterTable.foo1 
    ORDER BY 
        EquipmentDescription.DESCRIPTION
) 
SELECT * 
FROM somerows  
WHERE SeqValue BETWEEN 0 and 20

Background: Mastertable has 60,000+ records. I'm using WITH...as...etc to request 20 records at a time on the server side.

The DESCRIPTION column of EquipmentDescription for the purposes of design is not included in Mastertable. It is a requirement to include DESCRIPTION in the final select.

Any ideas on what I'm doing wrong?

Aucun commentaire:

Enregistrer un commentaire