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
 General SQL Server Forums
 New to SQL Server Programming
 error while creating function on remote server

Author  Topic 

saurabhpandey84
Starting Member

5 Posts

Posted - 2008-06-07 : 03:54:55
i have a function
Create Function ReturnAmountB(@CMID int) Returns Decimal
as
BEGIN
declare @Return decimal
select @Return =sum(PD_PaymentAmount) from Payment_Details where
PD_IsRefund=1 and PD_PaymentType=0 and PD_CMID=@CMID
return @Return
END

when i run this on server(remote) this error shows...
Incorrect syntex near 'Function'
Must declare the variable '@CMID'
A RETURN statement with a return value cannot be used in this context

i am not able to understand why this error shows...
Any solution!!!

spandey

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-07 : 04:07:39
quote:
Originally posted by saurabhpandey84

i have a function
Create Function ReturnAmountB(@CMID int) Returns Decimal(p,s)
as
BEGIN
declare @Return decimal(p,s)
select @Return =sum(PD_PaymentAmount) from Payment_Details where
PD_IsRefund=1 and PD_PaymentType=0 and PD_CMID=@CMID
return @Return
END

when i run this on server(remote) this error shows...
Incorrect syntex near 'Function'
Must declare the variable '@CMID'
A RETURN statement with a return value cannot be used in this context

i am not able to understand why this error shows...
Any solution!!!

spandey


Not sure if thats the problem, but you have missed specifying the precision and scale value for decimal.
Go to Top of Page

saurabhpandey84
Starting Member

5 Posts

Posted - 2008-06-07 : 04:49:11
still giving same errors like :-
Incorrect syntax near Function.
Must decalre variable @CMID.
The Return statement with a return value can not be used in this context.

spandey
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-07 : 04:56:43
quote:
Originally posted by saurabhpandey84

still giving same errors like :-
Incorrect syntax near Function.
Must decalre variable @CMID.
The Return statement with a return value can not be used in this context.

spandey


Cant spot anything obvious. Are you sure this is full code you used?
Go to Top of Page

saurabhpandey84
Starting Member

5 Posts

Posted - 2008-06-07 : 05:02:17
i am using the same function on local server n its running correctly but giving error on remote server...

spandey
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-07 : 05:13:01
quote:
Originally posted by saurabhpandey84

i am using the same function on local server n its running correctly but giving error on remote server...

spandey


Is the remote server also MS SQL Server box?
Go to Top of Page

saurabhpandey84
Starting Member

5 Posts

Posted - 2008-06-07 : 05:18:13
yes sir.
i am using SQL2000 server and the remote server is also SQL2000.
and function is working on local server but not on remote server.

spandey
Go to Top of Page
   

- Advertisement -