在sql server中创建表时如何锁定?

问题描述 投票:0回答:1

我正在尝试在同一应用程序的多个实例(在服务器上)运行此查询

我试图运行查询但会遇到死锁。

set transaction isolation level serializable
go
begin transaction
if not exists (select name from sys.sysobjects where name like 'xyp')
begin
    CREATE TABLE xyp( id varchar(1), name varchar(5));
end
commit transaction go

有什么我可以做的吗?

java sql-server jdbctemplate
1个回答
0
投票

为什么你需要在创建过程中锁定表?我不认为它可以在SQL Server中完成。您需要针对您的应用进行一些更改。

© www.soinside.com 2019 - 2024. All rights reserved.