Link to home
Start Free TrialLog in
Avatar of johnkainn
johnkainn

asked on

function if

In sql 2008 I call a function from stored procedure.

I would like to have an if statement in the function. Following returns error. How is best to do this?

ALTER FUNCTION [dbo].[myFunction](@GId int)

RETURNS TABLE
AS
      RETURN(

                     if @GId >0
                        begin
                                --...select statement
                        end
                    else
                      begin
                                 .....
                      end
        )
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnkainn
johnkainn

ASKER

Thank you.