SQL Server 怎样在Select语句中加行锁?

描述:当第一个人执行Select * from csdntable where id>1查询语句的过程中,不允许第二个人再次执行Select * from csdntable where id>1来查询这笔数据。求大神指点!(查了相关的资料,提示加RowLock,但是我做了实验,并没有成功)

http://blog.163.com/csdn_net/blog/static/82535471200891410481117/

参考:https://www.cnblogs.com/leohahah/p/7059852.html

可以在事务里先用Update做一个假的更新,然后再做后续处理

可以在 后面加上 for update nowait

Select * from csdntable where id>1 for update nowait

如果只是查询时限制,直接加事物锁表就行了