cookiemonster
cookiemonster

Reputation: 368

SQL Server column was specified multiple times

select 
    table12.* 
from 
    (select *
     from [Crimes].[FactCrimes] as fact
     inner join [Crimes].[DimCrimeClassification] as crime on fact.CrimeTypeID = crime.CrimeTypeID
     where[Index Code] = 'i') as table12;

but I keep getting this error:

The column 'CrimeTypeID' was specified multiple times for 'table12'

Upvotes: 0

Views: 4029

Answers (1)

Aswani Madhavan
Aswani Madhavan

Reputation: 816

use/specify column names in derived table instead of *. CrimeTypeID is present in both the tables and hence available twice in that query. Always use column names to avoid these kind of errors and better performance

Upvotes: 4

Related Questions