English 中文(简体)
病媒“什么地方”条款的恰当方式?
原标题:Elegant way for "where" clause by vector?

表:

name |   isActive       //(bit -  not nullable)
___________________
a          1
b          1
c          0
d          0
...        ...

在《倡议》中:

“entergraph

如果用户只希望<代码>,即可选择。 活性产品,Nonactives, Nothing

创造能够具有其中一种价值的病媒: 11,10,01,00

10 = 主动给予我,主动给予我——非活跃分子。

01 = 给我不积极的东西,给我——积极分子

11 给我......

  00 nothing ...

这是一开始。

但是,看上<条码>的条码>中最强的<>。 我询问中的条款:

我开枪:

select ...
WHERE  isActive = CASE  WHEN LEFT(@vector, 1) = RIGHT(@vector, 1)
       AND RIGHT(@vector, 1) =  1  THEN isActive
         ELSE 
          ... ( more option calculations ( bad and long and non elegant ...)

           END

any elegant help ?

最佳回答

I don t understand what do you mean by 00 - NOTHING. Actually, it means that you don t need to execute the query.
You can try this:

...
WHERE isActive=@isActive OR @isActive IS NULL

请注意<代码> 页: 1

但这一询问不会使用<代码>isActive上的索引。

问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签