Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The multi-part identifier could not be bound [duplicate]

Tags:

sql

Possible Duplicate:
The multi-part identifier could not be bound

This is my query that doesn't want to work.

It says: The multi-part identifier "dbo.RunSequenceBatch.RunSequenceBatchName" could not be bound.

Could you please advise?

Thanks in advance!!! :)

SELECT '30 May' AS [Date],
[RunSeq].[RunSequenceBatchName] AS [Batch Job Name] ,
RunSeqCat.CategoryDescription AS [Development Name] ,
[Systems].SystemName AS [System Area] ,
CAST((SUM(DumpSM37_Env3.Duration) / 60) AS NUMERIC(10, 2)) AS [Duration (mins)] 
FROM [dbo].[RunSequenceBatch] AS RunSeq 
LEFT JOIN DumpSM37_Env3 ON ([RunSeq].[RunSequenceBatchName] =  DumpSM37_Env3.[Job] 
AND DumpSM37_Env3.[ImportDate] BETWEEN  '30 May 2012 00:00:00' AND '30 May 2012 23:59:59'), 
[dbo].[RunSequenceType] AS RunSeqType, 
[dbo].[RunSequenceFrequency] AS RunSeqFrequency, 
RunSequenceCategory AS RunSeqCat, Category, [Systems]  
WHERE RunSeq.Status = 'Active' 
AND RunSeqFrequency.RunSequenceBatchID  = RunSeq.RunSequenceBatchID 
AND RunSeq.RunSequenceTypeID = RunSeqType.RunSequenceTypeID 
AND RunSeqCat.CategoryDescription = Category.Description 
AND Category.SystemArea = [Systems].SystemID 
AND DumpSM37_Env3.[Duration] > 0 
AND RunSeq.RunSequenceTypeID = 1 
AND RunSeqCat.RunSequenceBatchID = RunSeq.RunSequenceBatchID  
GROUP BY dbo.RunSequenceBatch.RunSequenceBatchName, DumpSM37_Env3.WorkerProcessID, 
ORDER BY [RunSeqFrequency].[Frequency] ASC, 
[RunSeqFrequency].[StartTime] ASC
like image 824
user1425357 Avatar asked May 30 '12 07:05

user1425357


People also ask

What is multipart identifier?

A multipart identifier is any description of a field or table that contains multiple parts - for instance MyTable. SomeRow - if it can't be bound that means there's something wrong with it - either you've got a simple typo, or a confusion between table and column.

How do I fix the ambiguous column name in SQL?

You may see an error that says something like Column 'id' in field list is ambiguous . This error means that there is a field name that is present in more than one table, so it needs to be scoped with the table name to avoid ambiguity: using orders.id instead of just id will resolve the issue.

Could not be bound meaning?

could not be bound. The main reason for this error is that the source table cannot be found, for example if you have statement such as Table1. OrderDate, and then if you get error above, this means that Table1 cannot be found in the query.

How do you fix subquery returned more than 1 value this is not permitted when the subquery follows != <= >= Or when the subquery is used as an expression?

Answer: This error message appears when you try to use subquery (correlated or not) that returns more than one value to the calling query. This usually indicates that there are duplicate entries in the column of a table where it's expected to be unique.


1 Answers

Basically, you've mismatched your table names.

In your FROM you have:

FROM [dbo].[RunSequenceBatch] AS RunSeq 

You're aliasing [dbo].[RunSequenceBatch] In other words, you're stating that from here on out, [dbo].[RunSequenceBatch] will be referred to as RunSeq

But in your GROUP BY you don't refer to it using the alias. Because the alias in the only exposed name in the query, dbo.RunSequenceBatch can't be bound.

Change

GROUP BY dbo.RunSequenceBatch.RunSequenceBatchName

to

GROUP BY RunSeq.RunSequenceBatchName

And you'll be fine.

like image 53
Code Magician Avatar answered Nov 11 '22 19:11

Code Magician