我想在sql server的情况下创建多个if语句。 有没有可能请给我举一个例子。 在c#中,您可以在案例中编写多行语句。如何在SQL Server的Case语句内执行多个If语句
是否有可能在SQL Server中像C#switch case一样。
我希望把下面的代码的情况下,环
IF @SegmentId > 0 and @AttributeName IS NOT NULL
begin
select AttributeID,Attribute_key from AttributeMaster
where AttributeTypeId [email protected] and [email protected]
and Attribute_key like '%'[email protected]+'%' order by AttributeID
end
else IF @SegmentId = 0 and NULLIF(@AttributeName, '') IS NULL
begin
select AttributeID,Attribute_key from AttributeMaster
where AttributeTypeId [email protected] order by AttributeID
end
else IF @SegmentId > 0 and NULLIF(@AttributeName, '') IS NULL
begin
select AttributeID,Attribute_key from AttributeMaster
where AttributeTypeId [email protected] and [email protected]
order by AttributeID
end
我需要实现@AttributeTypeId
是1个,那么不同的条件。 [email protected]
from 1 to 5
你想达到什么样的SQL查询在你的问题中提到/别的条件?你能否在preudo-code代码片段中提供你的问题。 –
[你有什么尝试](http://whathaveyoutried.com)?你看过BEGIN/END关键字吗? – Oded
我必须在sql server中实现一种开关情况类型的条件。只是简单的查询是可能的情况下,我可以执行其他条件变化。 –