Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Error checking in subqueries

Author  Topic 

fantom75
Starting Member

1 Post

Posted - 2012-06-18 : 14:38:50
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
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2012-06-18 : 14:45:53
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
   

- Advertisement -