Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to set MSSQL result to text

Posted on 2010-08-13
5
Medium Priority
?
687 Views
Last Modified: 2012-05-10
I have a few queries that count the amount of documents that are run, and it also displays the amount of seconds since the last document was processed. What I would like to do, is when there are no more documents to process, instead of displaying a 0, I would like to display a text indicating that there are no more pending documents. Here's what I have:

COUNT(CASE WHEN success IS NULL AND processed_dts IS NULL THEN 'No documents to process' END)

If I take out the COUNT, I will get an error because I am not using an aggregate function.

Thanks...
0
Comment
Question by:horalia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Expert Comment

by:vdr1620
ID: 33432597
Try this..
CASE WHEN COUNT(success) IS NULL AND COUNT(processed_dts) IS NULL THEN 'No documents to process' END

I would be better to post your complete code with some sample data
0
 
LVL 8

Expert Comment

by:mustaccio
ID: 33432618
Try using MAX() instead of COUNT()
0
 
LVL 3

Accepted Solution

by:
man2002ua earned 2000 total points
ID: 33436218
Hmm
CASE  WHEN SUM(CASE WHEN success IS NULL AND processed_dts IS NULL THEN 0 ELSE 1 END) = 0
   THEN  'No documents to process'
ELSE
  CAST(SUM(CASE WHEN success IS NULL AND processed_dts IS NULL THEN 0 ELSE 1 END) AS VARCHAR)
END
0
 

Author Comment

by:horalia
ID: 33599600
Thanks for all your comments experts, I was on vacation the last two weeks, I'm currently trying out man2002ua suggestion, will continue updating this question... Thanks!
0
 

Author Closing Comment

by:horalia
ID: 33643660
Worked like a charm! Thanks! Sorry for the delay in closing this question...
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are some very powerful Dynamic Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a di…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question