Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想插入一个表,但阻止插入另一个表。例如,可以锁定表a以进行插入,插入表b,然后解锁表a?
TABLOCK 只能锁定我正在插入的表。
谢谢
马丁·皮尔奇
SQL Server 不允许像信号量那样锁定对象。此外,锁定表不会使其成为只读;它会让每个人都锁定它。
您可以通过使用表提示来放置锁,SELECT * FROM MyTable WITH (LOCKNAME)但这不是一个好的编程习惯。
SELECT * FROM MyTable WITH (LOCKNAME)