Hi,

I'm trying to make an user fonction designed on a T-SQL statement like this:

DECLARE @MyParam int
DECLARE @InferedParam int
SET @MyParam = 1
SET @InferedParam= (SELECT MyColumn FROM Table WHERE Table.Column = @MyParam)

IF (@InferedParam= 1)
BEGIN

[First Statement here: simple select]

END
ELSE
BEGIN

[Second Statement here: simple select]

END

I want my function return either the first or the second statement, but it seems that the function does not handle the IF correctly.

I've still suceed to define some user function like this:

CREATE FUNCTION MyFunction (@MyParam int)
RETURNS TABLE AS
RETURN
(
SELECT *
FROM Table
WHERE Table.Column = @MyParam
)

Does anyone have any hint?

Thankls alot!

Gauthier