我有以下代码:
CREATE FUNCTION db_owner.GetComp
(
@CompID bigint,
@ComponentType nvarchar(50)
)
RETURNS TABLE
AS
RETURN /* SELECT ... FROM ... */
IF (@ComponentType = 'WMCOMP') begin
RETURN
SELECT *
FROM WMCOMP
WHERE wmcompid = @CompID
end
ELSE IF (@ComponentType = 'ADECOMP') begin
RETURN
SELECT *
FROM ADECOMP
WHERE adecompid = @CompID
end
尝试将其保存在 Visual Studio 中时,显示以下错误:
IF 附近的语法不正确
我根本看不出有什么问题。任何帮助将不胜感激。