I don't know what I'm missing. I have tried to run the following SQL from inside a QueryDef in Access (2003) but it keeps coming back with the error :
[Microsoft][SQL Server Native Client 11.0][SQL Server]The multi-part identifier "tW.WE" could not be bound (#4104)
That error text actually occurs four times in total in the message.
Clearly, the SQL that Access uses is different from this in layout but this is what I pasted into the QueryDef SQL window and it accepted it happily enough.
I looked through The multi-part identifier "%.*ls" could not be bound. and played around with the names of both the table and the field to try to ensure they wouldn't clash with anything else but none of the changes had the desired effect. I couldn't derive any more from what it was saying than that. Nothing else seemed relevant to this situation. Maybe I'm missing something.
For reference, all three tables are linked tables to the SQL Server 12 BE.
[Avail] stores availability records per Employee (BranchID,EmpID ) per Week (W/E). The cartesian product of [Employees] and [tblWE] reflects all possible [Avail] records for the range, but only those that don't match existing records are appended.
I also tried it without the table ALIAS of [tW], just using [tblWE] throughout. This had the same problem, reported as dbo.tblWE.WE.
[Microsoft][SQL Server Native Client 11.0][SQL Server]The multi-part identifier "tW.WE" could not be bound (#4104)
That error text actually occurs four times in total in the message.
Code:
INSERT INTO Avail ( [BranchID] , [EmpID] , [W/E]) SELECT [sqAllAvail].[BranchID] , [sqAllAvail].[EmpID] , [sqAllAvail].[W/E] FROM (SELECT [tE].[BranchID] , [tE].[EmpID] , [tW].[WE] AS [W/E] FROM [Employees] AS [tE] , [tblWE] AS [tW] WHERE ([tE].[Status]='C') AND ([tW].[WE] Between GetWE('w-3') And GetWE('w13'))) AS [sqAllAvail] LEFT JOIN [Avail] ON ([sqAllAvail].[BranchID]=[Avail].[BranchID]) AND ([sqAllAvail].[EmpID]=[Avail].[EmpID]) AND ([sqAllAvail].[W/E]=[Avail].[W/E]) WHERE ([Avail].[W/E] Is Null)
I looked through The multi-part identifier "%.*ls" could not be bound. and played around with the names of both the table and the field to try to ensure they wouldn't clash with anything else but none of the changes had the desired effect. I couldn't derive any more from what it was saying than that. Nothing else seemed relevant to this situation. Maybe I'm missing something.
For reference, all three tables are linked tables to the SQL Server 12 BE.
GetWE()
is a function that returns a Sunday date. The parameter 'w-3' means 3 weeks before the Sunday on or following today, and 'w13' means 13 weeks after.[Avail] stores availability records per Employee (BranchID,EmpID ) per Week (W/E). The cartesian product of [Employees] and [tblWE] reflects all possible [Avail] records for the range, but only those that don't match existing records are appended.
I also tried it without the table ALIAS of [tW], just using [tblWE] throughout. This had the same problem, reported as dbo.tblWE.WE.
Comment