问题描述
|
我如何基于2位列返回OR,它们也可以为空。
解决方法
tsql使用与c#和其他c语言相同的按位运算符。即|或,&表示&,而^表示异或。
一个最适合您的问题的示例:
select (column1 | column2) from [YourTable];
如果要测试所有选项,则可以尝试此功能块并测试各种可能性。
declare @col1 bit = 0 /** or 1 or null */
declare @col2 bit = 0 /** or 1 or null */
declare @col3 bit = null
set @col3 = (@col1 | @col2)
在此处阅读更多信息:http://msdn.microsoft.com/en-us/library/ms176122.aspx