2列的逻辑运算(逻辑或)

2列的逻辑运算(逻辑或)

问题描述:

如何根据2位列返回OR,它们也可以为空。2列的逻辑运算(逻辑或)

+0

更新下面简单的SELECT语句我的答案,也许更多的是你所期待的。 – RThomas 2011-05-31 17:44:55

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