34,587
社区成员
发帖
与我相关
我的任务
分享
use test
go
if not object_id('T') is null
drop table T
Go
Create table T([ID] int,[Name] nvarchar(2),[Sex] nvarchar(2))
Insert T
select 1,N'N1',N'S1' union all
select 2,N'N2',N'S2' union all
select 3,N'N3',N'S3'
Go
連接1:
begin tran
Select * from T with(updlock,rowlock) where ID=1
/*
ID Name Sex
----------- ---- ----
1 N1 S1
(1 個資料列受到影響)
*/
連接2:
begin tran
Select * from T with(updlock,READPAST)
/*
ID Name Sex
----------- ---- ----
2 N2 S2
3 N3 S3
(2 個資料列受到影響)
*/
--rollback