What is the best way to convert an int or null to boolean value in an SQL query, such that:
Assuming you want 0,1 value as a return, and that we are talking about integer I would use the logic specified by Torbjörn and wrap it in the function
create function dbo.isNotNull(@a int)
returns bit
as
begin
return isnull(@a-@a+1,0)
end
so then you can use it whenever you need by simply calling
select dbo.isNotNull(myIntColumn) from myTable
The answer provided by Tomalak is more universal though as it would work with any data type