Timeout that added 1,000,000 rows in the database (sometimes)

I am developing a C # library with .NET Framework 4.0, Entity Framework 6.1.3 and SQL Server 2012.

I have this stored procedure which I am calling with Ado.net

:

CREATE PROCEDURE [dbo].[InsertCodes]
      @codes as dbo.SerialAndValueList READONLY -- Codes
    , @username nvarchar(50)            
    , @source nvarchar(50)              
    , @column2 tinyint                  
AS
    Declare @codesCount int;

    set nocount on;

-- =========== CODE =============   
    INSERT INTO Code (Serial, Column1, Column2, Column3, UserName, Source)
        SELECT Serial, Column1, @column2, @column3, @username, @source FROM @codes

    IF (@@ERROR != 0)
        RETURN -1 -- Database error

RETURN 0

      

And SerialAndValueList

:

CREATE TYPE [dbo].[SerialAndValueList]
AS TABLE
(
    Serial nvarchar(20),
    Column1 tinyint
)

      

I am using it to store 1,000,000 Serials ( @codes

has 1,000,000 lines).

I am testing it with the same amount of codes and sometimes I get a timeout exception and sometimes I don't.

I found the article Configure Remote Request Server Wait Setting , suggesting:

EXEC sp_configure 'remote query timeout', 0 ;  
GO  
RECONFIGURE ;  
GO

      

But if I do, I want to disable it only in this stored procedure (at the beginning) and re-enable it before leaving it.

Another question is that the timeout only happens 60 seconds after the stored procedure is started, but here the remote request timeout is read , I see the default value is 600 seconds.

How can I get the current value of the Remote Request Timeout parameter in my database?

Or, how can I fix this problem?

+3


source to share


1 answer


Remote XXX timeouts refer to timeouts for outgoing remote requests running on the server. outbound request to linked server, settings do not affect incoming requests from client.



If you want to set a higher timeout .CommandTimeout

that is available on ObjectContext

and SqlCommand

.

+3


source







All Articles