Sql – How to output a boolean in T-SQL based on the content of a column

sqlsql-server-2000

I made a view to abstract columns of different tables and pre-filter and pre-sort them. There is one column whose content I don't care about but I need to know whether the content is null or not. So my view should pass an alias as "true" in case the value of this specified column isn't null and "false" in case the value is null.

How can I select such a boolean with T-SQL?

Best Solution

You have to use a CASE statement for this:

SELECT CASE WHEN columnName IS NULL THEN 'false' ELSE 'true' END FROM tableName;