Monday, January 17, 2011

Ambigous column name in TSQL Query

If you encounter this error in your TSQL query embedded in C#, you might want to check the table it is being joined. It might be that some field in the other table has the same fieldname.


Orders - status varchar(90)
OrdersSubForm - status varchar(30)

Just make sure, you create a prefix of the table name plus the dot and append it in your field. Just like the example below, for the status field.
1:  select   
2:   Orders.status,  
3:   OrderNum  
4:  from Orders  
5:  right outer join OrderSubForm  
6:  on OrderSubForm.ID = Orders.ID  
7:  where (your condition here)  


Post a Comment