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.
我们使用具有大量记录的表。任何人都知道是否更好地制作 Count(*) 或 Top 1 以了解特定记录是否存在或一组记录是否符合某些条件。还有这种类型的语句锁表或者我需要指定不锁表。
如果你不关心脏读的可能性,你可以试试这个
SELECT TOP(1) FROM YourTable WITH (NOLOCK) WHERE ..... (your conditions here)