Click here to Skip to main content
15,891,976 members
Home / Discussions / Database
   

Database

 
AnswerRe: Subqueries Pin
Wonde Tadesse20-Dec-15 15:28
professionalWonde Tadesse20-Dec-15 15:28 
AnswerRe: Subqueries Pin
Mycroft Holmes20-Dec-15 19:15
professionalMycroft Holmes20-Dec-15 19:15 
QuestionSynchronising number of disconnected databases to a central DB. Pin
srinandan..14-Dec-15 17:45
srinandan..14-Dec-15 17:45 
AnswerRe: Synchronising number of disconnected databases to a central DB. Pin
Mycroft Holmes14-Dec-15 18:52
professionalMycroft Holmes14-Dec-15 18:52 
GeneralRe: Synchronising number of disconnected databases to a central DB. Pin
srinandan..14-Dec-15 22:20
srinandan..14-Dec-15 22:20 
GeneralRe: Synchronising number of disconnected databases to a central DB. Pin
Mycroft Holmes15-Dec-15 11:44
professionalMycroft Holmes15-Dec-15 11:44 
GeneralRe: Synchronising number of disconnected databases to a central DB. Pin
Eddy Vluggen15-Dec-15 11:53
professionalEddy Vluggen15-Dec-15 11:53 
QuestionSQL Server deadlocks Pin
Member 1115415113-Dec-15 6:42
Member 1115415113-Dec-15 6:42 
I'm dealing with a strange (for me) situation in SQL Server.
I'm having a process that locks the same table twice. If the same time that the first process is locking the table a second process tries to lock the same table a deadlock happens immediately. Is this normal?
I wrote a script and run it twice from different connections.
Here is the script:
SQL
begin tran myTran
create table anyTable (anyColumn varchar(10), primary key (anyColumn))

declare @exec datetime, @i int, @m varchar(2), @x int
set @exec = getdate()
set @m = substring(convert(varchar, @exec, 120), 15, 2)
set @x = convert(int, @m) + 1

print 'Before Lock anyTable for 1st time. Time = ' + convert(varchar(40), getdate())	--remove for the second process (victim)
update anyTable set anyColumn = anyColumn												--remove for the second process (victim)
print 'After Lock anyTable for 1st time. Time = ' + convert(varchar(40), getdate())		--remove for the second process (victim)

while datediff(ms, @exec, convert(datetime, substring(convert(varchar, @exec, 120), 1, 14) + right(rtrim(ltrim(convert(varchar, @x))), 2) + ':00.000')) > 0
begin
	print 'Waiting. Time = ' + convert(varchar(40), @exec)
	set @exec = getdate()
end

print 'Before Lock anyTable for 2nd time. Time = ' + convert(varchar(40), getdate())
update anyTable set anyColumn = anyColumn
print 'After Lock anyTable for 2nd time. Time = ' + convert(varchar(40), getdate())

drop table anyTable

commit tran myTran

GeneralRe: SQL Server deadlocks Pin
Kornfeld Eliyahu Peter13-Dec-15 7:17
professionalKornfeld Eliyahu Peter13-Dec-15 7:17 
GeneralRe: SQL Server deadlocks Pin
Member 1115415113-Dec-15 19:41
Member 1115415113-Dec-15 19:41 
GeneralRe: SQL Server deadlocks Pin
Kornfeld Eliyahu Peter13-Dec-15 20:23
professionalKornfeld Eliyahu Peter13-Dec-15 20:23 
GeneralRe: SQL Server deadlocks Pin
Member 1115415113-Dec-15 20:36
Member 1115415113-Dec-15 20:36 
GeneralRe: SQL Server deadlocks Pin
Member 1115415114-Dec-15 0:00
Member 1115415114-Dec-15 0:00 
SuggestionRe: SQL Server deadlocks Pin
Richard Deeming14-Dec-15 2:50
mveRichard Deeming14-Dec-15 2:50 
GeneralRe: SQL Server deadlocks Pin
Member 1115415116-Dec-15 2:28
Member 1115415116-Dec-15 2:28 
Questionneed to consult about project discussion Pin
divinity technologies10-Dec-15 22:14
divinity technologies10-Dec-15 22:14 
AnswerRe: need to consult about project discussion Pin
Mycroft Holmes11-Dec-15 1:26
professionalMycroft Holmes11-Dec-15 1:26 
QuestionCreating Access database with VB6 Pin
Member 121949778-Dec-15 18:05
Member 121949778-Dec-15 18:05 
AnswerRe: Creating Access database with VB6 Pin
Mycroft Holmes8-Dec-15 20:46
professionalMycroft Holmes8-Dec-15 20:46 
GeneralRe: Creating Access database with VB6 Pin
Member 121949778-Dec-15 21:03
Member 121949778-Dec-15 21:03 
GeneralRe: Creating Access database with VB6 Pin
Mycroft Holmes9-Dec-15 1:23
professionalMycroft Holmes9-Dec-15 1:23 
AnswerRe: Creating Access database with VB6 Pin
CHill609-Dec-15 5:29
mveCHill609-Dec-15 5:29 
GeneralRe: Creating Access database with VB6 Pin
Member 121949779-Dec-15 21:18
Member 121949779-Dec-15 21:18 
GeneralRe: Creating Access database with VB6 Pin
CHill6010-Dec-15 5:23
mveCHill6010-Dec-15 5:23 
QuestionHow to update sequence in MySQL Pin
Jassim Rahma8-Dec-15 4:10
Jassim Rahma8-Dec-15 4:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.