Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Error - Invalid Object Name

Author  Topic 

darenkov
Yak Posting Veteran

90 Posts

Posted - 2004-11-17 : 00:35:26
Hi, I put this message up yesterday but forgot to make an appropriate subject header.

I am trying to create a basic function with the following syntax:

CREATE FUNCTION Addition(@Number1 Decimal(6,2), @Number2 Decimal(6,2))
RETURNS Decimal(6,2)
BEGIN
DECLARE @Result Decimal(6,2)
SET @Result = @Number1 + @Number2
RETURN @Result
END

The problem is that whenever I call it with the code below:

PRINT mydatabase.dbo.Addition(1450, 228)

I get the following error:

Error: Invalid object name 'nobleaccounting.dbo.Addition'

I am 100% sure that the database name is correct. Any ideas what else the problem could be?

I tried the nest the call statement as suggested by SeventhNight:

PRINT (SELECT(mydatabase.dbo.Addition(1450, 228))

but that gave me the following error:

Error: Subqueries are not allowed in this context. Only scalar expressions are allowed

Any ideas?

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-11-17 : 00:47:40
select mydatabase.dbo.addition(1450,228)
or
print mydatabase.dbo.addition(1450,228) worked also

--where did you create the object? is mydatabase correct? is the owner of the object dbo?
--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -