I need to query two tables in two different databases on the same SQL Server. On one table, I need to get all the rows (simple select) and on the other, a select but where the id matches a parameter in my stored proc.
I tried doing this but get the error
The multi-part identifier could not be bound.
How can I go about this?
QUERY:
SELECT QUALITY_CENTER, POSTCODE_ID, (SELECT [QCID]
FROM [Website_Interactive].[dbo].[IIPCentre_UserObject]
WHere LoginID = @loginID)
FROM IIP_QC_LIST
Sounds like you mistyped something. You can query a table in another DB using the following method:
I purposely added a two word database name because you have to put square brackets around that for it to be recognized. Your Schema will most likely be
dbo.If you show us your query and give us the DB names I can provide a more complete answer.
UPDATE:
Are you sure you are spelling “Center” correctly? I noticed you spelled it “centre” in
IIPCentre_UserObjectwhich I think might be right for the UK (?) but you spelled it “center” forQUALITY_CENTER. I would assume it’s spelled one way or the other in your environment.