SQL Server视图中的IF条件 [英] IF condition in view in SQL Server
本文介绍了SQL Server视图中的IF条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可能在视图中具有if条件
Is it possible to have a if condition in VIEWS
例如
CREATE VIEW
as
DECLARE @Count int
SET @Count=-1
select @Count=EmpID from EmployeeDetails where ID=200
IF @Count=-1
BEGIN
SELECT * FROM TEAM1
END
ELSE
BEGIN
SELECT * FROM TEAM1
END
推荐答案
不,我不相信这个有可能。
No I don't believe this is possible.
您可以使用存储过程来实现此功能。
You could use a stored procedure instead to achieve this functionality.
这篇关于SQL Server视图中的IF条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文