Receiving "deadlock" error message

I have a query on a page that gets called from a cfdiv. Basically the div refreshes and runs the query every minute.

I am receiving the below error periodically. Does anyone know how to prevent this in ColdFusion?

Thank you.

Diagnostics: Error Executing Database Query. [Macromedia][SQLServer JDBC Driver][SQLServer]Transaction (Process ID 74) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
The error occurred on line 55
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Deadlocks are a BIG topic.  If you do a search on "sql server deadlocks" there are a lot of good threads. However, you'll notice there's no one-size-fits all cure.  You need to do some tracing to find out which objects and queries are involved and why it's occurring.  Only then can you can figure out how to resolve the deadlock. You'd need to post the query, table ddl's and error messages involved for us to provide more specific advice.

In the interim, you could do what the error message suggests.  Add some cftry/cfcatch code that traps the deadlock error and retries the query a specified number of times.  It's not a solution, but it's the only graceful way to handle a deadlock error until you pinpoint the cause and try and resolve it.

EDIT: In most all cases deadlocks are strictly on the sql server side and really have nothing to do with ColdFusion.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Add some cftry/cfcatch code that traps the deadlock error

Be sure the cfcatch clause is granular and only handles deadlock errors by checking the SQLState or NativeErrorCode value.  No point retrying a query that will fail every time, like if the query contains bad values or syntax errors.
earwig75Author Commented:
Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.