Question Locked

Nested functions in T-sql

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi, I am trying to call a scalar user function
from an inline function, but it is not working.
If I declare a variable and assign the function
to it, it works!, but when I try to call the function directly from another function, I get
an error. The code is the following:

Declare @fecha1 datetime
Declare @fecha2 Datetime

Set @fecha2 = '10/02/2008'
-- if I use the function here, it is fine
Set @fecha1 = dbo.MesUnoStr(@fecha2)
Select * From Prop_MP_Per(@fecha1,@fecha2)

-- but if I use the function inside another
-- (as a parameter) I get a parse error
-- (before actually executing the code)
Select * From Prop_MP_Per(dbo.MesUno(@fecha2),@fecha2)

I appreciate If someone could help me.

Thanks for your help!!

3 replies

by abdullah.adam

I was able to parse it just fine in SQL Server 2005 Management Studio

by tony hopkinson

If you did, check the compatibility mode of the database, should be 90.
Causes all sorts of funnies in SQL2005 and hardly ever tells you what's really wrong.

This discussion is closed to new replies.