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.
| Author |
Topic |
|
saurabhpandey84
Starting Member
5 Posts |
Posted - 2008-06-07 : 03:54:55
|
| i have a functionCreate Function ReturnAmountB(@CMID int) Returns DecimalasBEGINdeclare @Return decimalselect @Return =sum(PD_PaymentAmount) from Payment_Details where PD_IsRefund=1 and PD_PaymentType=0 and PD_CMID=@CMIDreturn @ReturnENDwhen 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 contexti 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 functionCreate Function ReturnAmountB(@CMID int) Returns Decimal(p,s)asBEGINdeclare @Return decimal(p,s)select @Return =sum(PD_PaymentAmount) from Payment_Details where PD_IsRefund=1 and PD_PaymentType=0 and PD_CMID=@CMIDreturn @ReturnENDwhen 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 contexti 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. |
 |
|
|
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 |
 |
|
|
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? |
 |
|
|
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 |
 |
|
|
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? |
 |
|
|
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 |
 |
|
|
|
|
|