Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Multi-part identifier could not be bound

Author  Topic 

kiekar
Starting Member

7 Posts

Posted - 2008-09-05 : 15:33:30
Hello,

I am receiving an error each time I try to save the query. I'm using
SQL 2005 express through VS 2008.

The multi-part identifier "ChecklistItemCategories.ChecklistItemCategoryID" could not be bound.
The mulit-part identifie "ChecklistComponents.ChecklistItemCategoryID" cound not be bound.



SELECT ChecklistDetailID, IARRegistrationChecklistID, ChecklistComponentID, CheckedComponent, QCCategory, ISARP, QCObservation, IPM_AH, Action,
VerifiedBy,
(SELECT ChecklistComponentID FROM ChecklistComponents
WHERE ChecklistDetails.ChecklistComponentID = ChecklistComponents.ChecklistComponentID ) AS Component,
(SELECT ChecklistItemCategoryID FROM ChecklistItemCategories
WHERE ChecklistItemCatgories.ChecklistItemCategoryID = ChecklistComponents.ChecklistItemCategoryID) AS CategoryDescription
FROM ChecklistDetails


http://www.enter-net.com/~kkieslin/Select.jpg

Your help would be much appreciated.

Thanks

Karl

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-09-05 : 15:49:33
Why aren't you using joins instead of these subqueries?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-09-05 : 15:52:16
[code]
SELECT
cd.ChecklistDetailID, cd.IARRegistrationChecklistID, cd.ChecklistComponentID,
cd.CheckedComponent, cd.QCCategory, cd.ISARP, cd.QCObservation, cd.IPM_AH,
cd.[Action], cd.VerifiedBy, cc.ChecklistComponentID AS Component,
cic.ChecklistItemCategoryID AS CategoryDescription
FROM ChecklistDetails cd
INNER JOIN ChecklistComponents cc
ON cd.ChecklistComponentID = cc.ChecklistComponentID
INNER JOIN ChecklistItemCategories cic
ON cc.ChecklistItemCategoryID = cic.ChecklistItemCategoryID
[/code]

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

kiekar
Starting Member

7 Posts

Posted - 2008-09-05 : 18:25:46
Hello,

Thank you for your help. I have one other question. I modified your suggestion to add a WHERE clause.


SELECT
cd.ChecklistDetailID, cd.IARRegistrationChecklistID, cd.ChecklistComponentID,
cd.CheckedComponent, cd.QCCategory, cd.ISARP, cd.QCObservation, cd.IPM_AH,
cd.[Action], cd.VerifiedBy, cc.ChecklistComponentID AS Component,
cic.ChecklistItemCategoryID AS CategoryDescription
FROM ChecklistDetails cd
INNER JOIN ChecklistComponents cc
ON cd.ChecklistComponentID = cc.ChecklistComponentID
INNER JOIN ChecklistItemCategories cic
ON cc.ChecklistItemCategoryID = cic.ChecklistItemCategoryID
WHERE cd.ChecklistDetailID = @ChecklistDetailID


When I bind the stored procedure to a detailsview control, the cc.ChecklistComponentID AS Component and cic.ChecklistItemCategoryID AS CategoryDescription are displayed as id intergers. What would I need to modify in the query to display the actual string for the id intergers, e.g ChecklistItemCategoryID 1 = TitlePage and ChecklistComponentID 1 = AuditeeName

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-09-05 : 18:51:14
Then put those columns in the SELECT part of the query.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -