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 |
|
pareshmotiwala
Constraint Violating Yak Guru
323 Posts |
Posted - 2010-07-27 : 08:17:04
|
| I have the following subroutine:out: SELECT @error_code AS NativeErrorCode, @RedGateExitCode AS RedGateCode, @SQLErrorCode AS SQLCodeSET NOCOUNT OFF--SELECT @out_codeexit(SELECT @out_code)GOThis fails in sqlcmd/osql saying invalid syntax near Exit:Does anybody have ideas?If I uncomment the select @out_code, then I can run it via SSMS.RegardsParesh MotiwalaBoston, USA |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-07-27 : 11:50:33
|
| Your requirement is not much clear for me.A small clarifiction:The extract is part of function or SP ?Do you want to return any value from the routine ?If its a function you can use return statement.If its a SP then you can pass an output parameter and return the value.If you requirement is something different then post more detailed info. |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-07-27 : 12:09:15
|
quote: Originally posted by pareshmotiwala I have the following subroutine:out: SELECT @error_code AS NativeErrorCode, @RedGateExitCode AS RedGateCode, @SQLErrorCode AS SQLCodeSET NOCOUNT OFF--SELECT @out_codeexit(SELECT @out_code)GOThis fails in sqlcmd/osql saying invalid syntax near Exit:Does anybody have ideas?If I uncomment the select @out_code, then I can run it via SSMS.RegardsParesh MotiwalaBoston, USA
EXIT is not a valid TSQL command. You need to use RETURN.CODO ERGO SUM |
 |
|
|
pareshmotiwala
Constraint Violating Yak Guru
323 Posts |
Posted - 2010-07-27 : 14:20:10
|
| PK_Bohra: yes we want to return the value from the routines.and Valentine Jones: This command is being used with SQLCMD utility and it seems is a valid command.Thanks for the help.BTW, this job has been running for ages, I just changed the server and recreated the job. The new version of the server is SQL2008 R2/RegardsParesh MotiwalaBoston, USA |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-07-27 : 15:17:27
|
quote: Originally posted by pareshmotiwalaValentine Jones: This command is being used with SQLCMD utility and it seems is a valid command...
You should read SQL Server Books Online to see the actual syntax of the EXIT command within SQLCMD.CODO ERGO SUM |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|