Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

how to convert the following udf function into a stored procedure?

Hi Experts,
Can someone help me convert the following function into a stored procedure?

CREATE FUNCTION [dbo].[fnOrientLastNoteID]
(
	@Orientationid	AS	int
)
RETURNS int
AS
BEGIN
	DECLARE @Result AS int 

	select @Result =   MAX(ID) 
FROM         dbo.OrientationNotes
where OrientationID = @OrientationID;
--GROUP BY OrientationID  -- you don't need to group
	RETURN @Result;
END

GO

Open in new window

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Mark Ely
Mark Ely
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
CREATE PROCEDURE [dbo].[procOrientLastNoteID]
(
      @Orientationid      AS      int
)
AS
SET NOCOUNT ON;

SELECT MAX(ID)
FROM      dbo.OrientationNotes
WHERE OrientationID = @OrientationID

GO
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Thanks you guys,
Perhaps you may as well know how can I get that to work in my Access App form?

See following.
https://www.experts-exchange.com/questions/28659574/How-to-call-a-sql-custom-function-from-an-Access-project.html?anchorAnswerId=40735042#a40735042
No worries... however just curious why did you choose ScottPletcher answer over mine.. Our answers were identical and I posted first?
Avatar of bfuchs

ASKER

Sorry, I meant to assign 400 for your answer
Already requested attention on this matter.
Avatar of bfuchs

ASKER

Corrected, Apologize for that..