0

My SQL scalar valued function is defined in the following code:

CREATE FUNCTION CtrAmount ( @Ctr_Id int ) RETURNS MONEY AS BEGIN DECLARE @CtrPrice MONEY SELECT @CtrPrice = SUM(amount) FROM Contracts WHERE contract_id = @Ctr_Id RETURN(@CtrPrice) END GO SELECT * FROM CtrAmount(345) GO 

But when it comes to the SELECT line, I am getting this error:

Msg 208, Level 16, State 3, Line 14 Invalid object name 'CtrAmount'. 
1
  • 2
    SELECT CtrAmount(345) - check about scalar and table user functions Commented Jan 25, 2016 at 11:13

1 Answer 1

2

Int(10) - unknown type

CREATE FUNCTION dbo.CtrAmount ( @Ctr_Id INT ) RETURNS MONEY AS BEGIN RETURN ( SELECT SUM(amount) FROM dbo.Contracts WHERE contract_id = @Ctr_Id ) END GO SELECT dbo.CtrAmount(345) GO 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.