Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UDF Question
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
UDF Question
Divers
Thread ID:
00713031
Message ID:
00713031
Vues:
45
Can I create a udf function that performs a query, that returns a single row with a single field, and then return the value of the single column/record?

Here is what I have tried:
CREATE FUNCTION CaseResourceCost  (@meetID int)  
RETURNS decimal(12,2) AS  
BEGIN 
        Declare @returnValue decimal(12,2)
        select isnull(sum(cocasedata.itemunitcost * coCaseData.ActualQty),0) as avgResCost
	FROM dbo.meetings  INNER JOIN  
	             dbo.meetproc  ON meetings.meetingnumber =meetproc.meetingnumber INNER JOIN 
	             dbo.cocasedata ON meetings.meetingnumber = dbo.cocasedata.meetingnumber 
	             where meetings.meetingnumber = @MeetID

      set @returnValue= avgResCost
      return (@returnValue)
END
But I get the following error
---------------------------
Microsoft SQL-DMO (ODBC SQLState: 42S22)
---------------------------
Error 207: Invalid column name 'avgResCost'.
Select statements included within a function cannot return data to a client.
---------------------------
OK
---------------------------
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform