Change a null value to false in a view

Hello- I have a bit field in a view that returns either true, false or NULL.

How can I transform any null value to be treated as 'false'?

Thanks
snyperjAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ephraim WangoyaCommented:
you could use case statement for that

select case when field is null then false else field end , .....
0
snyperjAuthor Commented:
Where would I insert that in the view? (using management studio) in the 'Column' field????

Also, please help with the syntax... the field name is 'auto_taxed'

Thanks
0
tim_csCommented:
What about just doing this instead of a case statement?

SELECT COALESCE(auto_taxed,0) AS auto_taxed
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

snyperjAuthor Commented:
Where does that get inserted in the view?  I am not understanding where to put that.  I need to incorporate it into an existing view that has several joins.  If I put that in the 'Column' field, Management Studio automatically surrounds it with quotes and it just returns the whole sql statement as a string in the view results.  Help!
0
tim_csCommented:
Please provide the query being used in the view.
0
TempDBACommented:
You can put it the definition of the view. While creating view, you do run select statement. Just you need to change that. You can alter your view as:-

alter view <viewname>
as
select
     t1.<col_1>,
     t1.<col_2>,
     value = case when t1.<col_3> is null then 'NULL'
                  else when t1.<col_3> = 0 then 'False'
                  else 'True'
                  end
   t1.<col_4>,
...
...
..
from <tablename> as t1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
snyperjAuthor Commented:
worked it out... thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.