How do I add a computed boolean (bit) column to a SQL Server table that depends on two other boolean columns? (I'd prefer a SSMS solution).
I can get a computed column with the correct values by using the following:
case when ([ColumnA]=(1)) AND ([ColumnB]=(0)) then (1) else (0) end
but then the resulting column is type int which falls over when I use the data in C#
Looking around, it seems I need to use a CAST statement but I haven't managed to work out the syntax. I know this doesn't work:
cast (case when ([ColumnA]=(1)) AND ([ColumnB]=(0)) then (1) else (0) end) as bit
What should I do?