34,588
社区成员
发帖
与我相关
我的任务
分享
set @str=N'insert into ulook(uname,cname,addtime) SELECT a.uname,'''+@cname +''',GETDATE()
FROM per as a WHERE CHARINDEX('',''+LTRIM(id)+'','', '','+@perid+','')>0
AND NOT EXISTS(SELECT 1 FROM ulook WHERE uname = a.uname AND cname = '''+@cname+''')'
exec sp_executesql @str
begin tran
select 1 from ulook with (tablockx) where 1>2
set @str=N'insert into ulook(uname,cname,addtime) SELECT a.uname,'''+@cname +''',GETDATE()
FROM per as a WHERE CHARINDEX('',''+LTRIM(id)+'','', '','+@perid+','')>0
AND NOT EXISTS(SELECT 1 FROM ulook WHERE uname = a.uname AND cname = '''+@cname+''')'
exec sp_executesql @str
commit tran
set @str= 'select * FROM dbo.per where dbo.per.id in ('+@perid+')'
exec sp_executesql @str
begin tran
select 1 from ulook with (tablockx) where 1>2
set @str=N'insert into ulook(uname,cname,addtime) SELECT a.uname,'''+@cname +''',GETDATE()
FROM per as a WHERE CHARINDEX('',''+LTRIM(id)+'','', '','+@perid+','')>0
AND NOT EXISTS(SELECT 1 FROM ulook WHERE uname = a.uname AND cname = '''+@cname+''')'
exec sp_executesql @str
set @str= 'select * FROM dbo.per where dbo.per.id in ('+@perid+')'
exec sp_executesql @str
commit tran
set @str= 'select * FROM dbo.per where dbo.per.id in ('+@perid+')'
exec sp_executesql @str
begin tran
select 1 from ulook with (tablockx) where 1<2
你的语句
commit tran
set @str=N'insert into ulook(uname,cname,addtime) SELECT a.uname,'''+@cname +''',GETDATE()
FROM per with (xlock, tablock) as a WHERE CHARINDEX('',''+LTRIM(id)+'','', '','+@perid+','')>0
AND NOT EXISTS(SELECT 1 FROM ulook WHERE uname = a.uname AND cname = '''+@cname+''')'
exec sp_executesql @str