I have simplified my function to the following:
create function [dbo].[UserSuperTeams](@ProjectId int)
returns table
as
return
if @ProjectId=0
begin
select TeamId from TblTeam t
union
select 0 as TeamId
end
else
begin
select t.TeamId from TblTeam t
union
select 1 as TeamId
end;
go
I cannot make it work.. It seems I have some syntax errors, but I cannot figure out how to make it work.. Any idea?