About 58 results
Open links in new tab
  1. sql - Case in Select Statement - Stack Overflow

    Jan 7, 2013 · I have an SQL statement that has a CASE from SELECT and I just can't get it right. Can you guys show me an example of CASE where the cases are the conditions and the results are from …

  2. sql server - How do I perform an IF...THEN in an SQL SELECT? - Stack ...

    Sep 15, 2008 · The CASE statement is the closest to IF in SQL and is supported on all versions of SQL Server.

  3. 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. Is th...

  4. sql - Case sensitive search in WHERE clause - Stack Overflow

    Dec 2, 2009 · I want to do a case sensitive search in my SQL query. But by default, SQL Server does not consider the case of the strings. Any idea on how to do a case sensitive search in SQL query?

  5. How do I do multiple CASE WHEN conditions using SQL Server 2008?

    What I'm trying to do is use more than one CASE WHEN condition for the same column. Here is my code for the query: SELECT Url='', p.ArtNo, p.[Description], ...

  6. sql server - case statement in SQL, how to return multiple variables ...

    Dec 2, 2011 · Depending on your use case, instead of using a case statement, you can use the union of multiple select statements, one for each condition. My goal when I found this question was to select …

  7. T-SQL CASE Clause: How to specify WHEN NULL - Stack Overflow

    I wrote a T-SQL Statement similar like this (the original one looks different but I want to give an easy example here): SELECT first_name + CASE last_name WHEN null THEN 'Max' ELSE 'Peter' EN...

  8. How can I SELECT multiple columns within a CASE WHEN on SQL …

    Nov 22, 2016 · This uses a delimiter '%' to split the merged columns. You can write your own split function depending on your needs (e.g. for handling null records or using complex delimiter for …

  9. SQL Server CASE .. WHEN .. IN statement - Stack Overflow

    May 18, 2011 · On SQL server 2005 I am trying to query this select statement SELECT AlarmEventTransactionTableTable.TxnID, CASE AlarmEventTransactions.DeviceID WHEN …

  10. Return Boolean Value on SQL Select Statement - Stack Overflow

    How to return a boolean value on SQL Select Statement? I tried this code: SELECT CAST(1 AS BIT) AS Expr1 FROM [User] WHERE (UserID = 20070022) And it only returns TRUE if the UserID exists on …