我有一个带参数的SQL Server 2005存储proc :@includeClosedProjects。
@includeClosedProjects
WHERE我想根据此参数控制一个子句。
WHERE
create proc sel_projects (@incClosedRel int = 1) as SELECT projectId, projectName FROM project WHERE CompletionStatusCID NOT IN (34, 35) <-- controlled by @incClosedRel
我想获取所有项目(不包括where子句),何时@incClosedRel =1。否则,请包含where子句。
@incClosedRel =1
SELECT projectId, projectName FROM project WHERE CompletionStatusCID NOT IN (34, 35) Or @incClosedRel = 1