SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Error checking in subqueries
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

fantom75
Starting Member

USA
1 Posts

Posted - 06/18/2012 :  14:38:50  Show Profile  Reply with Quote
One of our developers noticed that when he had an error in a subquery within an if exists statement, he did not get an error message when running the query.

So, in the query below, it doesn't throw an error even though there is an error in the syntax of the subquery. Has anyone seen this? Is this a known problem with TSQL?

select distinct teamRoleID, dbo.prmTeamRole.[name] as teamRoleName
from dbo.prTeam inner join dbo.prmTeamRole on dbo.prTeam.teamRoleID = dbo.prmTeamRole.id
where projectNumber='P00000060' and dbo.prTeam.status = 'A'
and resourceID in
(
select id
from dbo.[resource]
where selected=1 and isvalid = 1
and projectNumber = 'P00000060'
)

The error is that there is no such field as ID but SQL does not return an error.

yosiasz
Flowing Fount of Yak Knowledge

USA
1610 Posts

Posted - 06/18/2012 :  14:45:53  Show Profile  Click to see yosiasz's MSN Messenger address  Reply with Quote
yes this is a known problem...better use an inner join to resource

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000