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 Processing

Author  Topic 

GRAYWOLF
Posting Yak Master

106 Posts

Posted - 2009-02-12 : 03:23:04
How do you tell a WHILE loop to continue if there is a certain error? I want my loop skip the file and continue if the error is "Error 530: File does not exist:"

---------------------------

Working until "the morning sun sets the midnight sky on fire"!

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-12 : 03:28:34
Use IF ELSE OR CASE Statements

IF(ERROR_MESSAGE()= 'File does not exist')
required statements
ELSE
required statements

Jai Krishna
Go to Top of Page

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-12 : 03:31:41
U can utilise two key words BREAK ,CONTINUE in accordance with ur problem

CONTINUE
Causes the WHILE loop to restart, ignoring any statements after the CONTINUE keyword.


BREAK
Causes an exit from the innermost loop. Any statements that appear after the END keyword, marking the end of the loop, are executed.



Jai Krishna
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-12 : 03:46:08
try like this
while (cond)
begin
statements
IF(ERROR_MESSAGE()= 'File does not exist')
break
end--endof whileloop
Go to Top of Page
   

- Advertisement -