could someone provide some simple code to simulate a block. I want to test
a blocking script I want to implement on prod.
TIA
CExecute this on one connection:
create table ##foo (SomeColumn int)
go
begin transaction
insert into ##foo (SomeColumn) values (1)
waitfor delay '0:00:40' /* hold the transaction open for 40 seconds */
go
commit transaction
/*****************************/
Execute this on another connection:
select * from ##foo
Keith
"CD" <mcdye1@.hotmail.REMOVETHIS.com> wrote in message
news:%23PbFfLMeFHA.1920@.tk2msftngp13.phx.gbl...
> could someone provide some simple code to simulate a block. I want to
> test a blocking script I want to implement on prod.
> TIA
> C
>|||Try,
-- conn 1
use northwind
go
begin transaction
update orders
set orderdate = orderdate
-- conn 2
use northwind
go
select * from orders
Connection 2 will be blocked until you commit or rollback the transaction in
connection 1.
AMB
"CD" wrote:
> could someone provide some simple code to simulate a block. I want to test
> a blocking script I want to implement on prod.
> TIA
> C
>
>|||Look at tablockx holdlock keywords
these will hold locks on tables with in a block of code...
i.e.
create procedure ...
select @.nextid = id from foo with (tablockx holdlock)
/* tablockx forces an exclusive table lock
tablock to do a non-exclusive lock
holdlock tells SQL Server to hold locks for duration of the transaction */
update foo set [id] = [id]+ @.block
return @.nextid
...
this will prevent n users from getting the same id
GO
"CD" wrote:
> could someone provide some simple code to simulate a block. I want to test
> a blocking script I want to implement on prod.
> TIA
> C
>
>
Showing posts with label tia. Show all posts
Showing posts with label tia. Show all posts
Friday, March 30, 2012
Wednesday, March 7, 2012
How to set interval for geting trace data
Hi all,
Is this possible in Profiler or I have to do it by store procedures, and how
do I do that
tia
ZarkoAre you trying to get trace data at certain intervals, instead of doing it
continuoulsy? If so, I don't think there's a way out. Once you setup a
trace, it will continuously receive all the events.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Zarko Jovanovic" <mind_less_s_pa_mm_a_g_a_i_n_s_t@.bigfoot.com> wrote in
message news:1076486704.262545@.internet.fina.hr...
Hi all,
Is this possible in Profiler or I have to do it by store procedures, and how
do I do that
tia
Zarko
Is this possible in Profiler or I have to do it by store procedures, and how
do I do that
tia
ZarkoAre you trying to get trace data at certain intervals, instead of doing it
continuoulsy? If so, I don't think there's a way out. Once you setup a
trace, it will continuously receive all the events.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Zarko Jovanovic" <mind_less_s_pa_mm_a_g_a_i_n_s_t@.bigfoot.com> wrote in
message news:1076486704.262545@.internet.fina.hr...
Hi all,
Is this possible in Profiler or I have to do it by store procedures, and how
do I do that
tia
Zarko
Subscribe to:
Posts (Atom)