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 2005 Forums
 Transact-SQL (2005)
 Function Error Message

Author  Topic 

btamulis
Yak Posting Veteran

64 Posts

Posted - 2010-11-03 : 17:18:51
I want to create a function that returns the last docdate for an item in a large table (IV30300).

Here's my syntax -

USE FARGO;
GO
IF OBJECT_ID (N'item.fn_lastdocdate', N'IF') IS NOT NULL
DROP FUNCTION item.fn_lastdocdate;
GO
CREATE FUNCTION item.fn_lastdocdate (@item char(31))
RETURNS TABLE
AS
RETURN
(
select itemnmbr, max(docdate) as lastdocdate from IV30300 where @item = itemnmbr group by itemnmbr
);
GO

When I parse this - it runs fine - when I execute I get this error message -

Msg 2760, Level 16, State 1, Procedure fn_lastdocdate, Line 6
The specified schema name "item" either does not exist or you do not have permission to use it.

What am I doing wrong????

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-03 : 17:43:51
error is pretty clear. either there is no schema named item, or u dont have permission. what is your default schema? does it work if u use dbo as schema?
Go to Top of Page

btamulis
Yak Posting Veteran

64 Posts

Posted - 2010-11-04 : 00:39:39
Thanks Russell - it does work when I use dbo instead of item.

Go to Top of Page
   

- Advertisement -