DECLARE MC CURSOR READ_ONLY FOR
SELECT [Str]FROM #Windows_Auth_Orphan_User
OPEN MC
FETCH NEXT FROM MC INTO @cmd
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
print @cmd
Execute (@cmd)
END
FETCH NEXT FROM MC INTO @cmd
END
CLOSE MC
DEALLOCATE MC
Above code is taken from my first post window. let says we have 5 records for above cursor
while executed by cursor, it got error in 2nd records;
it should send to catch box and then throw message by
SELECT ERROR_NUMBER()ErrorNumber,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage
(which is working fine)
and should go back to cursor and start working on remaining records( for 3, 4 and 5 records).
but my code got stopped after throwing error message:crying:.
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)