I have a simple SQL query (SQL Server 2005) in which I select from a table containing multiple columns with BIT values. These columns are NULL, so they can contain NULL, 0 or 1.
There are quite a few of these columns, and in my query I want to return zero if the value is NULL. I am currently using ISNULL as follows:
SELECT Name, Age, ISNULL(LikesOranges,0), ISNULL(LikesApples,0), ISNULL(LikesPears,0)
FROM FoodPreferences
As I mentioned, there are many of these BIT columns (much more than in the simple example above). Is there a way that I can use ISNULL for multiple columns, such as:
SELECT ISNULL(*,0) FROM FoodPreferences
The above query does not work, but you get what I am trying to do, so I can avoid having to write an ISNULL statement for each column,
Thank.