SQL Azure Database – Msg 40197, Level 20 – The Service has Encountered an Error Processing Your Request. Please Try Again. Error Code 40549

SQL Azure Database - Msg 40197, Level 20 - The Service has Encountered an Error Processing Your Request. Please Try Again. Error Code 40549 erroricon While trying to help one of my clients, I was shown below error which was received using bulk insert command. The command was used to move data from Azure Blob Storage to SQL Azure Database. Let us see how to fix the error processing request.

Msg 40197, Level 20, State 1, Line 16
The service has encountered an error processing your request. Please try again. Error code 40549.

The file was big and error doesn’t come immediately. It takes several hours before we get error. I looked into the message I found 40549 which is another message number.

select * from sys.messages where message_id = 40549

Here is what it means.
Session is terminated because you have a long running transaction. Try shortening your transaction.

And now it makes perfect sense. Here was the T-SQL which they were using.

INSERT INTO HumanResource.EmployeeMaster
SELECT *
FROM OPENROWSET(BULK 'Employee.dat', DATA_SOURCE = 'blobsource',
       FORMATFILE='fmt/Employee.xml', FORMATFILE_DATA_SOURCE = 'blobsource') as data; 

SOLUTION/WORKAROUND

As per the error message and behavior, we need to reduce the size of batch to make the transaction shorter. When I searched ways to do that in BCP I landed up https://technet.microsoft.com/en-us/library/ms188267(v=sql.105).aspx (Managing Batches for Bulk Import).  I found ROWS_PER_BATCH parameter which worked like a charm.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

, , ,
Previous Post
SQL SERVER – Database Mirroring Login Attempt Failed With Error: ‘Connection Handshake Failed. There is No Compatible Encryption Algorithm. State 22
Next Post
SQL SERVER – Maintenance Plan – Backup Files Not Getting Deleted

Related Posts

Leave a Reply

Menu