Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dynamic User Defined Functions

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-05-02 : 07:30:01
Sam writes "Hi there,

I'm trying to set up a dynamic user defined function, and so far I think I can only do it via a case statement

myFunction(@FUNCTION_NAME)
BEGIN
CASE @FUNCTION_NAME
WHEN 'function1' THEN EXEC function1
WHEN 'function2' THEN EXEC function2
WHEN 'function3' THEN EXEC function3
ELSE EXEC function4
END
END

Actually I'm not even sure that will work, but I know I can't do it as follows

myFunction(@FUNCTION_NAME)
BEGIN
EXEC @FUNCTION_NAME
END

because I can only execute deterministic functions and extended functions from with a UDF.

The functions I want to execute are deterministic, I would just like to be able to avoid a huge CASE statement to switch on their name.

Any ideas?

CHEERS> SAM

p.s. I did search your FAQ and forums, and I couldn't find anything that directly addressed this issue."

X002548
Not Just a Number

15586 Posts

Posted - 2005-05-02 : 09:45:31
Well...first off...you don't EXEC udf's.

Second, if you have to pass in the value, why not just call it?

Are these stored procedure ofr udf's we're talking about?

I'm so confused.



Brett

8-)
Go to Top of Page
   

- Advertisement -