Created
May 28, 2018 23:43
-
-
Save jinan-kordab/6e4fd965c0478d40406a69c63771377d to your computer and use it in GitHub Desktop.
First instance on how to test and avoid SQL deadlock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DELETE FROM [dbo].[TBL_test_temp] | |
| DELETE FROM [dbo].[TBL_test_temp_two] | |
| INSERT [dbo].[TBL_test_temp] ([TESTCOLUMNONE], [TESTCOLUMNTWO],[PK]) VALUES | |
| (N'TTTTTTTT',N'TTTTTTTTTTTTTT',1) | |
| INSERT [dbo].[TBL_test_temp_two] ([TWOcolumnone], [TWOcolumntwo],[PK]) VALUES | |
| (N'AAAAAAAA',N'AAAAAAAAAAAAAA',1) | |
| --1 - one | |
| BEGIN TRAN; | |
| Update TBL_test_temp set | |
| TESTCOLUMNONE =N'TTTTTTTT', | |
| TESTCOLUMNTWO =N'TTTTTTTTTTTTTT' | |
| Where PK =1 | |
| And TESTCOLUMNONE =N'TTTTTTTT' | |
| AND TESTCOLUMNTWO = N'TTTTTTTTTTTTTT' | |
| COMMIT; | |
| --3 - three | |
| BEGIN TRAN; | |
| Update TBL_test_temp_two set | |
| TWOcolumnone =N'AAAAAAAA', | |
| TWOcolumntwo =N'AAAAAAAAAAAAAA' | |
| Where PK =1 | |
| And TWOcolumnone =N'AAAAAAAA' | |
| AND TWOcolumntwo = N'AAAAAAAAAAAAAA' | |
| COMMIT; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment