|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, August 15, 2009 1:42 AM
Points: 7,
Visits: 79
|
|
Want a function to execute another function based on the passing variable.
create function dbo.mycustomertest (@code varchar(10)) returns table as return select (case when @code= 'brm' then 'select * from dbo.employee ()' when @code='crm' then 'select * from dbo.myorder()' else 'unknown' end) as col1 -------------------------------------------------- select * from dbo.mycustomertest ('brm')
Result.-- select * from dbo.mycustomertest ('brm')
Instead i need the output of [select * from dbo.employees ]the above function ---------------------------------------------------- create function dbo.employee() returns table as return select * from employees ---------------------------------------------------
create function dbo.myorders() returns table as return select * from orders
-------------------------------------------------
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: 2 days ago @ 7:57 PM
Points: 6,998,
Visits: 13,949
|
|
Functions don't allow for dynamic calls. You're going to need to do that logic OUTSIDE of a function.
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|