• I'm sorry for asking something that simple. Why would you use a Cursor and a loop for updating the server when you can use an SQL UPDATE statement instead ?

    Let's see the chunk of code:

    -- Cycle through the ErrLogData table and insert the server's name

    DECLARE SrvName_Cursor CURSOR FOR

    SELECT [SQLServerName] FROM [ErrorLogStorage].[dbo].[ErrLogData] WHERE [SQLServerName] IS NULL

    OPEN SrvName_Cursor

    FETCH NEXT FROM SrvName_Cursor

    WHILE @@FETCH_STATUS = 0

    BEGIN

    UPDATE [ErrorLogStorage].[dbo].[ErrLogData] SET [SQLServerName] = @@servername

    FETCH NEXT FROM SrvName_Cursor

    END

    CLOSE SrvName_Cursor

    DEALLOCATE SrvName_Cursor

    I understand you are trying to update [ErrorLogStorage].[dbo].[ErrLogData].[SQLServerName] with @@servernave when that same column is null. Right ? Well, there is an UPDATE statement that can do the same thing without the cursor. It looks like this:

    UPDATE

    [ErrorLogStorage].[dbo].[ErrLogData]

    SET

    [SQLServerName] = @@servername

    WHERE

    [SQLServerName] IS NULL

    This code is much simple and faster than the cursor one.

    What do you think ?

    Regards from Argentina, South America.

    Ariel.