TSQL - IF EXISTS SELECT From Mulitple Tables

  • Thread starter Thread starter Jonathan Woods
  • Start date Start date
J

Jonathan Woods

Dear Gurus,

How do I determine if data exists from multiple tables in SQL Server
2000?

For example,

IF EXISTS
(
( SELECT ColA FROM TableA WHERE ... ) AND
( SELECT ColB FROM TableB WHERE ... )
)
BEGIN
-- Need to do something here
END


Thanks in advance...

Jonathan
 
Jonathan Woods said:
How do I determine if data exists from multiple tables in SQL Server
2000?

For example,

IF EXISTS
(
( SELECT ColA FROM TableA WHERE ... ) AND
( SELECT ColB FROM TableB WHERE ... )
)
BEGIN
-- Need to do something here
END

Rewrite it as
IF Exists (select...from TableA...) AND Exists (select...from
TableB...)

Another option would be
IF Exists (select... from TableA INNER JOIN TableB ON...)

You may get some better answers if you ask this question in a Sql Server
newsgroup instead of the C# one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top