views:

347

answers:

1

I have a process that (at night) take a large chunk of data in the form of a linq2sql query and dumps this as XML (sitemaps). My problem is that I'm sometimes is getting:

System.Data.SqlClient.SqlException: Transaction (Process ID XX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

This query in readonly and not necessary need to be "transaction safe". Can I write a process like this to avoid the exception?

EDIT:

Basically the code is:

foreach(Record record in MyDataContext.FatTableWithRecords) //about 50' records { //produce some XML (dumped to file when max 50' records or 10MB large) }

A: 

The code for the query would help debug your particular problem, but you could also look at using sql jobs and some of the sql server functionality like xmlauto and transaction isolation level read uncommitted to handle your needs.

BioBuckyBall