November 30, 2007 at 9:50 am
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
-------------------------------------------------
November 30, 2007 at 10:31 am
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?
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply