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 |
|
Sharon_DBA
Starting Member
7 Posts |
Posted - 2009-07-13 : 19:14:49
|
| Hi all,Why am I getting "A RETURN statement with a return value cannot be used in this context." with the following:declare @x intdeclare @fname varchar (255)declare @errorsave INTdeclare @result intset @X=0set @fname='D:\LOG\StatusReportJob.out'set @errorsave=0set nocount onwhile @X<10beginset @X=@X+1exec master..xp_fileexist @fname, @result output IF (@result = 1) begin select 'file '+@fname+' exists. Moving on...' goto DONE end else begin select 'file '+@fname+' does not exist. Continuing to loop and wait...' waitfor delay '00:00:01' end print @Xendendloop:set @errorsave=890done:RETURN @errorsaveThanks in advance,Sharon |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-07-13 : 19:20:04
|
RETURN with a value is only permitted when run inside a stored procedure.When code is extracted and run in a query window, RETURN doesn't allow a value. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
Sharon_DBA
Starting Member
7 Posts |
Posted - 2009-07-13 : 22:21:21
|
| Ah, yes...thank you very much... |
 |
|
|
|
|
|