Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using IF EXISTS inside CASE block in SQL

Hi

Can I use IF EXISTS inside CASE block in SQL (MS SQL SERVER 2000)?
if yes, how??? if you have example, it will help.

Thanks
Mayur
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Using IF EXISTS inside CASE block in SQL

IF EXISTS, is what exists?

SQL queries the database, so if you want only certain items, you use a WHERE
clause.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
...
Hi

Can I use IF EXISTS inside CASE block in SQL (MS SQL SERVER 2000)?
if yes, how??? if you have example, it will help.

Thanks
Mayur



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Using IF EXISTS inside CASE block in SQL

Hi Mayur,

Since EXISTS returns a boolean result you can potentially use it in the
searched form of the T-SQL CASE function. The example shown below, from one
of my databases, returns a report name and a string indicating whether or
not a benchmark exists for that report in another table.

SELECT r.ReportUniqueName,
CASE
WHEN EXISTS (SELECT ReportID
FROM ReportBenchmarks
WHERE ReportID = r.ReportID)
THEN 'Has Benchmark' ELSE 'No Benchmark' END
FROM Reports AS r

I wouldn't say this is the most efficient way to write the query, but it
does work.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

wrote in message
...
Hi

Can I use IF EXISTS inside CASE block in SQL (MS SQL SERVER 2000)?
if yes, how??? if you have example, it will help.

Thanks
Mayur



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Block cell if specific condition exists WildWill Excel Discussion (Misc queries) 8 March 16th 09 05:50 AM
change data of entire column from small case to upper case Ann Excel Worksheet Functions 1 August 16th 08 01:06 PM
Changing multiple cell text from lower case to upper case Patti Excel Discussion (Misc queries) 2 January 4th 08 08:35 PM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
Change the text from lower case to upper case in an Excel work boo dave01968 Excel Discussion (Misc queries) 2 December 9th 05 09:09 AM


All times are GMT +1. The time now is 06:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"