tags:

views:

90

answers:

4

When I try to run the following statement, an error message is returned: Server: Msg 208, Level 16, State 1, Line 1 Invalid object name 'vendortofaultypeitemsmap'.

SQL Help indicates this message appears when "an object that does not exist is referenced". This table does exist and returns values if I run *select * from vendortofaulttypeitemsmap*. Can someone help me pinpoint what is wrong with the statement below that is causing the error message? Thanks in advance.

select 
    vendortofaulttypeitemsmap.vendorid, 
    vendortofaulttypeitemsmap.faultypeitemguid,
    guid_faulttypeitems.faulttypeitemname,
    vendortoworkactionmap.workactionitemguid, 
    guid_workactionitem.workactionitemname
from vendortofaultypeitemsmap
    inner join guid_faulttypeitems on
    vendortofaulttypeitemsmap.faultypeitemguid=
     guid_faulttypeitems.faultypeitemguid
    inner join guid_workactionitem on
    vendortoworkactionmap.workactionitemguid= 
     guid_workactionitem.workactionitemguid
where vendortofaulttypeitemsmap.vendorid=45
+1  A: 

You have a typo. It is either vendortofaultypeitemsmap or vendortofaulttypeitemsmap.

Otávio Décio
Thanks for the help. I must have looked at it 20 times and never saw the typo.
Erin Karschnik
@Erin - no problem, an extra pair of eyes is always good.
Otávio Décio
+2  A: 

You missed a 't' vendortofaultTypeitemsmap.

orthod0ks
A: 

This is where table aliases are a godsend!

dotjoe
+1  A: 

Writing those table names out every time makes it easy to make typos. Use table aliases to simplify the whole thing, and change it to:

select v.VendorID, v.FaultTypeItemGUID, f.FaultTypeItemName, 
       v.WorkActionItemGUID, w.WorkActionItemName 
from VendorToFaultTypeItemsMap v
inner join GUID_FaultTypeItems f on v.FaultTypeItemGUID = g.FaultTypeItemGUID 
inner join GUID_WorkActionItem w on v.WorkActionItemGUID = w.WorkActionItemGUID
where v.VendorID = 45

With long names like that, using mixed case can also help you spot problems easier (assuming your database isn't set to case-sensitive).

BradC