【发布时间】:2011-05-16 03:18:28
【问题描述】:
我在 Filter 类中有以下 4 个属性。我将解析以下 4 个属性到 StoredProcedure 并获得过滤后的结果。
/// <summary>
/// Gets and sets comma seperated condition ids.
/// Patients must have all these conditions in order to satisfy the filter.
/// </summary>
public string MustHaveAllConditions { get; set; }
/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must not have all of these conditions in order to satisfy the filter.
/// </summary>
public string MustNotHaveAllConditions { get; set; }
/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must have at least one of these conditions in order to satisfy the filter.
/// </summary>
public string MustHaveAtLeastOneCondition { get; set; }
/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must not have at least one of these conditions in order to satisfy the filter.
/// </summary>
public string MustNotHaveAtLeastOneCondition { get; set; }
我的存储过程将有四个参数,如下所示。 例如:
@*MustHaveAll*Conditions = "1,2"
@*MustNotHaveAll*Conditions = "3,4"
@*MustHaveAtLeastOne*Condition = "5,6,7,8"
@*MustNotHaveAtLeastOne*Condition = "9, 10"
我正在使用一个 UDF,它返回一个带有 Ids 列的表。
我的问题:
基本上我可以使用 SQL“IN”运算符来查找具有至少一个 Condition 的患者(即:@MustHaveAtLeastOneCondition)和“NOT IN”运算符组合来过滤 @MustNotHaveAnyConditions。
是否有任何 SQL 运算符(或其他方法)来过滤 MustHaveAllConditions、MustNotHaveAllConditions 参数?
【问题讨论】:
标签: sql sql-server-2008 stored-procedures user-defined-functions