Timeout expired with SqlBulkCopy

I’m using SqlBulkCopy to restore tables from xml backups. One of the table backup is ~200MB large and has a lot of records.

I’m having error:

  • FOR XML SQL Server - Variable Element name in output XML
  • show create table tablename (how do i do this in sql server)?
  • SQL Server - How to filter rows based on matching rows?
  • How to correct a SQL Server Syntax Error setting FK contrainsts?
  • SQL Server Convert integer to binary string
  • how to create temp table while Joining multiple tables that have to be PIVOT
  • Timeout expired.
    The timeout period elapsed prior to completion of the operation or the server
    is not responding.

  • SQL Server 'Resume Next' Equivalent
  • How can I have two columns in SQL Server auto increment?
  • Returning the original value if it doesn't match any of the when_expressions
  • Suggestions for SQL Server GUI?
  • Looping RecordSet Destination in SSIS Script Task
  • How to find date ranges in records with consecutive dates and duplicate data
  • 3 Solutions collect form web for “Timeout expired with SqlBulkCopy”

    You probably need to increase the timeout. Try increasing the value of sqlBulkCopy.BulkCopyTimeout from the default which is 30 seconds.

    There are two ways to fix this error:

    • Increase Timeout by default it is 30 second and 0 means infinite.

         sqlBulkCopy.BulkCopyTimeout = {time in seconds}
    • Decrease BatchSize by default it try to insert all rows in one batch

          sqlBulkCopy.BatchSize  = {no of rows you want to insert at once}


    Change the CommandTimeout property of your SqlCommand object.

    The Connect Timeout attribute of a connection string determines how long a SqlConnection Object runs before it stops attempting to connect to a server.

    Also change the SqlBulkCopy.BulkCopyTimeout Property.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.