UDF: working in one DB but not another

  • Thread starter Thread starter eantar
  • Start date Start date
E

eantar

Can someone help on this.

I've got a UDF Scalar Function that works fine in on database, but when
I try to copy the same UDF to another database I get syntax error
messages.

The function is:
ALTER FUNCTION dbo.GetDateFilled
(
@dateAt1 datetime,
@dateAt2 datetime,
@dateEndActual datetime
)
RETURNS datetime
AS
BEGIN
Declare @dateFilled datetime
If @dateAt1 Is Not Null And @dateAt2 Is Null
set @dateFilled = @dateAt1
Else
If @dateAt1 Is Null And @dateAt2 Is Not Null
set @dateFilled = @dateAt2
Else
If @dateAt1 Is Null And @dateAt2 Is Null
set @dateFilled = @dateEndActual
Else
Set @dateFilled = @dateAt1
RETURN @dateFilled
END

And this isn't the only UDF I can't import from one DB to another. It
seems that I can't import any???
Any ideas would be greatly appreciated:

ea
 
Wouldn't that need to be CREATE FUNCTION rather than ALTER FUNCTION the
first time it is run?

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
It doesn't seem to matter if I use Create or Alter Function. Any idea
why I would get syntax errors on code that works in one DB but not
another???

Thanks,
EA
 
What does the error message say? Is there an error number?

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top