Re: Problem with nested function call (UDFs)



On Sun, 22 Jul 2007 00:42:01 +0200, Gert-Jan Strik wrote:

Sorry about the confusion. I first tested on SQL Server 2000 and later
(when Hugo gave a reply) I retested on 2005.

In SQL Server 2005, this all works just fine. All you need to do is
access the scalar UDF with its 2-part name.

However, in SQL Server 2000 (the OP's platform), it doesn't work.
Calling it with the 2-part name gives the error "Incorrect syntax near
'.'", calling it with the 1-part name gives the error "Incorrect syntax
near '('.". Schemabinding doesn't make a difference.

Hi Gert-Jan,

I missed both the requirement of the OP that it run under SQL2000 and
the odd behaviour on that platform.

I can confirm the same behaviour here. And I can't find any explanation
in Books Online. I guess it's a bug - but not one I expect to ever see
fixed.

The workaround is of course simple:

DECLARE @d datetime
SET @d = dbo.get_current_quarter(GetDate())
SELECT id, dt
FROM (SELECT 1, CAST('20070701' AS datetime)
UNION ALL
SELECT 2, CAST('20070815' AS datetime)) AS t(id, dt)
WHERE dt IN (SELECT TheDate
FROM dbo.get_trxns_for_quarter(@d));


--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
.



Relevant Pages

  • Re: Select Expression Operators
    ... Thanks Hugo. ... >>Sorry for what must seem like a dumb question, but I was wondering why I keep ... > SQL Server doesn't offer the same set of functions as Access and it ... > ISNULL will return the second expression if the first is NULL. ...
    (microsoft.public.sqlserver.mseq)
  • Re: Views
    ... Yes, Hugo, your description is perfect. ... SQL Server sometimes decides to materialize the view ... complicated queries, ... then you appear to have run into a bug. ...
    (microsoft.public.sqlserver.clients)
  • Re: Shrinking a logfile -
    ... Thank you, both Hugo and bass_player, for your explanations. ... think it's worth highlighting a bit more - shrinking database files ... if for whatever reason a file has grown to way more than its ... reason and aso know it will probably happen again, then SQL Server ...
    (microsoft.public.sqlserver.setup)
  • Re: using a trigger to enforce referential integrity
    ... You the man, Hugo!!! ... > When I have to mimic other users on my dev system, I use SQL Server ... This requires setting the SQL Server authentication mode ... > authentication and provide the login name and password for the test user. ...
    (microsoft.public.sqlserver.programming)
  • Re: percentages of top 10 tallies
    ... Hugo is using what is called a derived table. ... Columnist, SQL Server Professional ... My solution uses less IO and yours has the lowest query cost. ... >Hi Tom, ...
    (microsoft.public.sqlserver.programming)