Skip to content

Instantly share code, notes, and snippets.

@EvanCarroll
Created July 27, 2009 21:34
Show Gist options
  • Save EvanCarroll/156749 to your computer and use it in GitHub Desktop.
Save EvanCarroll/156749 to your computer and use it in GitHub Desktop.
The errors in error.txt resulted from having written a storedproc, when I wanted to write
a user-defined scalar function. The problem, and solution are named appropriately in
this archive.
## Getting these two errors:
Msg 195, Level 15, State 10, Line 1
'get_monthly_payment' is not a recognized built-in function name.
Msg 4121, Level 16, State 1, Line 1
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.get_monthly_payment", or the name is ambiguous.
USE [dealermaiddata]
GO
/****** Object: StoredProcedure [dbo].[get_monthly_payment] Script Date: 07/27/2009 15:27:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Evan Carroll
-- Create date: 07/11/2009
-- Description: Calculates Monthly Payments
-- =============================================
ALTER PROCEDURE [dbo].[get_monthly_payment]
-- Add the parameters for the stored procedure here
@price numeric = null,
@apr numeric = null,
@term int = null
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
RETURN
CAST (
( @price * (@apr/100.0/12.0) * power( (1+@apr/100.0/12.0), @term ) )
/ ( power( (1+@apr/100.0/12.0), @term) -1 )
AS numeric(8,2)
)
END
alter function dbo.get_monthly_payment (
@price numeric(8,2),
@apr numeric(8,2),
@term int
)
returns numeric(8,2)
AS
BEGIN
-- Insert statements for procedure here
RETURN
CAST (
( @price * (@apr/100.0/12.0) * power( (1+@apr/100.0/12.0), @term ) )
/ ( power( (1+@apr/100.0/12.0), @term) -1 )
AS numeric(8,2)
)
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment