I am testing my application I need some code that stable simulates the deadlock on database site (sql script if possible).
The best way would be to use tables you already have. Create two tables -- table-a, table-b For a test you can even update the same column with the same information so you don't affect any real data.
For instance UPDATE table_a set ID = ID where ID = 100;
Open two sessions to the same database. On one, run
On two run
Then, copy the update statements to the opposing sessions and run at the same time. In one,
I just tried this now and got on MS-SQL
Use the sp_getapplock system stored procedure to take what ever locks to need on your sample code.
Here's another method similar to the one posted above -->
Script to be used in Query Window #1
Script to be used in Query Window #2
Script to be added to Query Window #1
For additional details on this, refer to http://ajitananthram.wordpress.com/2014/02/23/scripts-to-force-a-deadlock-in-sql-server/