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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 @@ERROR

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-30 : 23:55:48
Farouk writes "Could anyone help me with the following:

SET @INT = 1
SET @COUNT = 100

WHILE (@INT <> @COUNT)
BEGIN
INSERT INTO TABLE (C1, C2, C3)
VALUES (2, 4, 6)
IF (@@ERROR <> 0)
BEGIN
--SKIP THE CURRENT INSERTION BUT CARRY ON
END
SET @INT = @INT + 1
END


...Say for instance that the insertion fails when @INT = 9, this would mean that only records upto 8 would be inserted. I require the insertion to log the row with the error (9), skip No. 9 and continue inserting from 10 until 100.

The question is, is this possible?
And if it is, I would appreciate you response."
   

- Advertisement -