Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:17:13+00:00 2026-06-11T10:17:13+00:00

I have a valid SQL select which returns an empty result, up and until

  • 0

I have a valid SQL select which returns an empty result, up and until a specific transaction has taken place in the environment.

Is there something available in SQL itself, that will allow me to return a 0 as opposed to an empty dataset? Similar to isNULL(”, 0) functionality. Obviously I tried that and it didn’t work.

PS. Sadly I don’t have access to the database, or the environment, I have an agent installed that is executing these queries so I’m limited to solving this problem with just SQL.

FYI: Take any select and run it where the “condition” is not fulfilled (where LockCookie=’777777777′ for example.) If that condition is never met, the result is empty. But at some point the query will succeed based on a set of operations/tasks that happen. But I would like to return 0, up until that event has occurred.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:17:15+00:00Added an answer on June 11, 2026 at 10:17 am

    You can store your result in a temp table and check @@rowcount.

    select ID
    into #T
    from YourTable
    where SomeColumn = @SomeValue
    
    if @@rowcount = 0
      select 0 as ID
    else
      select ID
      from #T
    
    drop table #T
    

    If you want this as one query with no temp table you can wrap your query in an outer apply against a dummy table with only one row.

    select isnull(T.ID, D.ID) as ID
    from (values(0)) as D(ID)
      outer apply
        (
          select ID
          from YourTable
          where SomeColumn = @SomeValue        
        ) as T
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL SELECT statement which will not be known until runtime, which
Right now I have this SQL query which is valid but always times out:
I have the following SQL to be queried. It is a valid SQL. Unfortunately,
If I have theses general sql valid dates in c# strings : (each date
I'm trying to write a query to tell me which orders have valid promocodes.
I have an sql query that requires repeating the same SELECT statement a number
I have the following code: $sql = mysql_query(SELECT id FROM logins WHERE id=' .
i have a gridview which is populating from sql datasource defined at designed, i
I have a function which executes a select statement. When I attempt to execute
I'm currently getting the error: java.sql.SQLException: ORA-01843: not a valid month which I assume

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.