[英]Subquery returned more than 1 value. This is not permitted when the subquery follows … or when the subquery is used as an expression
I know subquery return more than 1 value but I don't know how to change the code.我知道子查询返回超过 1 个值,但我不知道如何更改代码。 Can anyone help me?谁能帮我?
declare @sProjectNumber nvarchar(200)
( select Project from Project_Table where Project in (
select case
when @sProject is null then (select distinct Project from Project_Table)
else @sProject end
from Project_Table)
)
I am guessing that you really intend something like this:我猜你真的打算这样:
select Project
from Project_Table
where @sProject is NULL or Project = @sProject;
This will return the project in @sProject
or all projects if that value is NULL
.如果该值为NULL
,这将返回@sProject
中的项目或所有项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.