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 2008 Forums
 Transact-SQL (2008)
 Help converting function to SQL 2000

Author  Topic 

evanburen
Posting Yak Master

167 Posts

Posted - 2010-04-05 : 13:31:18
I have this function which works in SQL 2008 but I need something similar for an instance of SQL 2000 but receive the error message 'Select statements included within a function cannot return data to a client.'

CREATE FUNCTION dbo.f_TotalRealizedCompensation_SP500

RETURNS int
--WITH RETURNS NULL ON NULL INPUT
AS
BEGIN
-- Declare the return variable here
DECLARE @Return int

SELECT AVG(ceototactcomp) FROM dbo.CompanyData
WHERE INDEXSP = 'S&P 500'

-- Return the result of the function
RETURN @Return

END
GO

evanburen
Posting Yak Master

167 Posts

Posted - 2010-04-05 : 15:50:54
I was able to work this out
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-05 : 16:19:15
SELECT @Return = AVG(ceototactcomp)
FROM dbo.CompanyData
WHERE INDEXSP = 'S&P 500'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -