You need the ISNULL function.
SELECT ISNULL(a, b)
b
gets selected if a
is null.
Also, you can use the WHEN/THEN select option, lookup in BOL. Essentially: its c switch/case block meets SQL.
More Related Contents:
- Calculate a Running Total in SQL Server
- Not equal != operator on NULL
- SET NOCOUNT ON usage
- How can I get column names from a table in SQL Server?
- How can I select the first day of a month in SQL?
- Truncate (not round) decimal places in SQL Server
- Select statement to find duplicates on certain fields
- Is it possible to specify condition in Count()?
- Getting only Month and Year from SQL DATE
- Update records in table from CTE
- Dynamic Pivot Columns in SQL Server
- WHERE Clause vs ON when using JOIN
- Is it possible to select sql server data using column ordinal position
- Selecting N rows in SQL Server
- @@IDENTITY, SCOPE_IDENTITY(), OUTPUT and other methods of retrieving last identity
- How can I INSERT data into two tables simultaneously in SQL Server?
- SQL “select where not in subquery” returns no results
- How can a LEFT OUTER JOIN return more records than exist in the left table?
- “select * from table” vs “select colA, colB, etc. from table” interesting behaviour in SQL Server 2005
- Dynamic SQL to generate column names?
- Pivot data in T-SQL
- Column name or number of supplied values does not match table definition
- Split one column value into multiple column values
- How to find consecutive rows based on the value of a column?
- T-SQL – Aliasing using “=” versus “as” [closed]
- Which SQL query is faster? Filter on Join criteria or Where clause?
- SQL Query – Concatenating Results into One String [duplicate]
- Know relationships between all the tables of database in SQL Server
- How to escape square brackets inside square brackets for field name
- Convert bigint to datetime