the follow SQL returns the following error.
where[dbo].[exist] (select companyname from companies where companyintid = 'CM00006070');
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'select'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ')'.
This query probably doesn't make any sense. If the EXISTS predicate returns true (i.e., there is a row in the 'companies' table with that 'companyintid'), you'll get back every row from the 'company' table. If it returns false, you'll get back no rows.I'm betting what you really want is something closer to:SELECT CompanyIntIdFROM CompanyWHERECompanyName IN(SELECT CompanyNameFROM CompaniesWHERE CompanyIntId = 'CM00006070')... but it's hard to say, since you haven't provided us with DDL or sample data to back up your requirements.
Pro SQL Server 2005, available now
--""Nitin Khurana"@discussions.microsoft.com" <"=?UTF-8?B?Tml0aW4gS2h1cmFuYQ==?="@discussions.microsoft.com> wrote in message news:firstname.lastname@example.org...
whereexists (select companyname from companies where companyintid = 'CM00006070');