About 138,000 results
Open links in new tab
  1. How do I perform an IF...THEN in an SQL SELECT?

    Sep 15, 2008 · SELECT CASE WHEN Obsolete = 'N' or InStock = 'Y' THEN 1 ELSE 0 END as Saleable, * FROM Product CASE statements can be embedded in other CASE statements …

  2. How to make a SQL "IF-THEN-ELSE" statement - Stack Overflow

    Aug 25, 2015 · 7 The IF/Else construct is used to control flow of statements in t-sql. You want a case expression, which is used to conditionally return values in a column. Yours would be …

  3. sql - can you do an ELSE WHEN on a CASE - Stack Overflow

    Nov 4, 2011 · No, ELSE is a catch-all. In your example, it's not clear why you would want to include a condition in the ELSE clause, since you've already checked the logically opposite …

  4. SQL Server IF EXISTS THEN 1 ELSE 2 - Stack Overflow

    Using Sql Server 2012. I have a stored procedure and part of it checks if a username is in a table. If it is, return a 1, if not, return a 2. This is my code: IF EXISTS (SELECT * FROM tblGLUserA...

  5. SQL "IF", "BEGIN", "END", "END IF"? - Stack Overflow

    It has to do with the Normal Form for the SQL language. IF statements can, by definition, only take a single SQL statement. However, there is a special kind of SQL statement which can …

  6. If else in stored procedure sql server - Stack Overflow

    If else in stored procedure sql server Asked 12 years, 3 months ago Modified 5 years, 11 months ago Viewed 596k times

  7. SQL: IF clause within WHERE clause - Stack Overflow

    Sep 18, 2008 · END ELSE BEGIN SELECT * FROM Table WHERE OrderNumber LIKE '%' + @OrderNumber END 3) Using a long string, compose your SQL statement conditionally, and …

  8. Best way to do nested case statement logic in SQL Server

    I'm writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions. I'm currently using nested case statements, but its getting messy. …

  9. SQL query, if value is null then return 1 - Stack Overflow

    SQL query, if value is null then return 1 Asked 12 years, 9 months ago Modified 8 years, 4 months ago Viewed 358k times

  10. Using Nested IF ELSE statements in sql - Stack Overflow

    First, your logic is failing because you have if/then/elseif. In other words, if something has a first name, last name, and date of birth, then they pass the first criteria.