How to set MSSQL result to text

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...
horaliaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
man2002uaConnect With a Mentor Commented:
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
 
vdr1620Commented:
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
 
mustaccioCommented:
Try using MAX() instead of COUNT()
0
 
horaliaAuthor Commented:
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
 
horaliaAuthor Commented:
Worked like a charm! Thanks! Sorry for the delay in closing this question...
0
All Courses

From novice to tech pro — start learning today.