C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Missing field in subquery doesn't raise any error


Posted Date: 10 Mar 2004    Resource Type: Articles    Category: Databases
Author: Satheesh SugumaranMember Level: Gold    
Rating: Points: 5



If you run a SELECT query that references a non-existing column, SQL Server raises an error Invalid column name as we would expect. However, if the SELECT appears in a sub-query, SQL Server doesn't raise any error

In the following example, let's say that the Northwind's Customers table doesn't have any Citi field (note the mispelled name). The following query raises an error:

SELECT Citi FROM Customers 


Error: Invalid column name 'Citi'.

However, the following query doesn't raise any error, and returns records:

-- assume that the Region table doesn't contain a City field

SELECT * FROM Customers WHERE City IN (SELECT City FROM Region)


The problem seems to arise when the field appears in the main table, but not in the table mentioned in the subquery

Taking into consideration the above mentioned scenario ,it is good to be aware while using subqueries






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Swap the values of two columns
Previous Resource: Using ORDER BY clause in the definition of a view
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use