Reputation: 23
I’m trying to pull data from 2 tables:
• DolfinRMSCum.dbo.tSupplier
• DolfinRMSCum.dbo.tSupplierType
Both columns have a common field & value SupplierTypeCode
, hence the Join
But I want to see the Description column value from DolfinRMSCum.dbo.tSupplierType
in the query
> Select Supplier.SupplierNumber as [Dolfin Code]
> ,Supplier.SagesupplierCode as [Sage Code]
> ,Supplier.SupplierName as Name
> ,Supplier.PrimaryTel as Tel
> ,Supplier.PrimaryFax as Fax
> ,Supplier.PrimaryContact as Contact
> ,Supplier.SupplierTypeCode as [Supplier Type]
> ,DolfinRMSCum.dbo.tSupplierType.Description as [Type Description]
> ,Supplier.Add1 as [Add 1]
> ,Supplier.Add2 as [Add 2]
> ,Supplier.Add3 as [Add 3]
> ,Supplier.Add4 as [Add 4]
> ,Supplier.CountryCode as Country
> ,Supplier.CurrencyCode as Currency
> FROM DolfinRMSCum.dbo.tSupplier as Supplier,DolfinRMSCum.dbo.tSupplierType as SupplierType
> full outer join DolfinRMSCum.dbo.tSupplierType
> on DolfinRMSCum.dbo.tSupplier.SupplierTypeCode =
> DolfinRMSCum.dbo.tSupplierType.SupplierTypeCode
> where Deactivated=0
receiving the follwoing error:
Msg 4104, Level 16, State 1, Line 17
The multi-part identifier "DolfinRMSCum.dbo.tSupplier.SupplierTypeCode" could not be bound.
I have tried using aliases in the Join without any success as below:
Full outer Join DolfinRMSCum.dbo.tSupplierType as SupplierType ON SupplierType.SupplierTypeCode = Supplier.SupplierTypeCode
Upvotes: 1
Views: 407
Reputation: 13237
DolfinRMSCum.dbo.tSupplierType
is used two times in the FROM
clause. It can be mentioned in one time is enough. Also if you are apply table alias, then you can use the same in the SELECT
statement too.
Can you try the query below:
SELECT
Supplier.SupplierNumber as [Dolfin Code]
,Supplier.SagesupplierCode as [Sage Code]
,Supplier.SupplierName as Name
,Supplier.PrimaryTel as Tel
,Supplier.PrimaryFax as Fax
,Supplier.PrimaryContact as Contact
,Supplier.SupplierTypeCode as [Supplier Type]
,SupplierType.Description as [Type Description]
,Supplier.Add1 as [Add 1]
,Supplier.Add2 as [Add 2]
,Supplier.Add3 as [Add 3]
,Supplier.Add4 as [Add 4]
,Supplier.CountryCode as Country
,Supplier.CurrencyCode as Currency
FROM DolfinRMSCum.dbo.tSupplier AS Supplier
FULL OUTER JOIN DolfinRMSCum.dbo.tSupplierType AS SupplierType ON SupplierType.SupplierTypeCode = Supplier.SupplierTypeCode
WHERE Deactivated = 0
Upvotes: 1