Dominique
Dominique

Reputation: 17565

Why can't my fields be bound in the mentioned SQL query?

Here's some information on the relevant fields in my database:

SELECT *
  FROM INFORMATION_SCHEMA.COLUMNS
  WHERE UPPER(TABLE_NAME) LIKE '%Own_Customer.PRODUCTS%'
  AND ((UPPER(COLUMN_NAME) = 'ID') OR (UPPER(COLUMN_NAME) = 'NAME'))

Result:

TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_PRECISION_RADIX NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_CATALOG CHARACTER_SET_SCHEMA CHARACTER_SET_NAME COLLATION_CATALOG COLLATION_SCHEMA COLLATION_NAME DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME
Prod_Own_Customer dbo Own_Customer.Products Name 8 NULL NO varchar 255 255 NULL NULL NULL NULL NULL NULL iso_1 NULL NULL SQL_Latin1_General_CP1_CI_AS NULL NULL NULL
Prod_Own_Customer dbo Own_Customer.Products Id 10 NULL NO uniqueidentifier NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
SELECT [Own_Customer.Job].Name,[Own_Customer.Job].Status, [Own_Customer.JobPart].Id, [Own_Customer.JobPart].SequenceNr, [Own_Customer.JobPart].ProductId, [Own_Customer.Products].Name
  FROM [Own_Customer.Job], dbo.[Own_Customer.JobPart]
  WHERE [Own_Customer.Job].Id = [Own_Customer.JobPart].JobId AND
        [Own_Customer.JobPart].ProductId = [Own_Customer.Products].Id
ORDER BY [Own_Customer.Job].CreationDate, [Own_Customer.Job].Name, [Own_Customer.JobPart].SequenceNr, [Own_Customer.JobPart].Id

Result:

Msg 4104, Level 16, State 1, Line 10
The multi-part identifier "Own_Customer.Products.Id" could not be bound.
Msg 4104, Level 16, State 1, Line 7
The multi-part identifier "dbo.Own_Customer.Products.Name" could not be bound.

Some examples of the content in the columns "Name" and "Id" of "[Own_Customer.Products]":

Name Id
CHE APPELZUUR COATEC C12-65 (CONT) D1B79DE6-FAE5-4568-96FC-FA12EF2C4B02
CHE BIND GUAR 5000 CPS (CONT) AE5525E4-0230-43BC-A8D4-C21501F139A5
CHE FOSF SAPP B285 - E450I (CONT) F6C6C365-DBC5-449D-A0ED-70C98F89B197
CHE FOSF STPP XINGFA (CONT) 510696EE-F975-4490-AF34-EBE6938E2D4F
CHE NATRIUM BICARBONAAT (CONT) FDD76641-98DF-47FA-8C04-389D324B5BCE

What can I do in order to launch the desired SQL query? (The one with information about Jobs, JobParts and Products)
... just to start: why does SQL-Server think that the mentioned fields are multi-part identifiers? They're just names of IDs, nothing multipart about them.

Some more information

I don't know if this is relevant, but next to the dbo.Own_Customer.Products table, I also have a dbo.Products table.

I do not believe my question is a duplicate of this one. That question mentions quite a lot of possible answers, but the simple fact that I had forgotten to add a table in the FROM-clause is not mentioned or not easy to be found.

Upvotes: 0

Views: 76

Answers (0)

Related Questions