i know that, was an try to explain of what i want
The Dixie Flatline (8/25/2016)
EXEC(FunctionColumn) AS FunctionResultSorry, but functions can't call procedures. They can only call other functions. Period.
If I understand you correctly now, you want to be able to pass a string that is itself a calculation, and have the EXEC run that string to produce a results calculation. You aren't going to get there without doing dynamic SQL and performance is probably going to suffer some.
Could you explain why you feel the need to do this? What is so dynamic about the calculation strings you are dealing with?
i know you cant do EXEC(FunctionColumn) AS FunctionResult in a select statment
i even try something like this, even knowing that it may not work
create function dbo.calc_statment_in_column (@statment varchar(100), @param1 varchar(10))
returns varchar(100)
as
begin
declare @result varchar(100)
declare @query varchar(400)
set @query = N'SELECT @res = ' + @statment
EXEC sp_executesql @query
, N'@param varchar(10), @res varchar(100) OUTPUT'
, @param = @param1, @res = @result OUTPUT
return @result
end
--and use it like this, where the functionColumn has statments like "dbo.dummyfunction(@param)"
select column1
, functionColumn
, dbo.calc_statment_in_column( functionColumn, @param1 ) as functionResult
from mytable
and it didn't
but is this kind of aproach that i want to know if is possible
of corse excell does it better 🙂