locking - SQL Server : lock table to block other sessions trying to read the table -
i need able lock table in sql server while doing work. lock needs block other sessions reading table. when work complete table needs unlocked.
in mysql have done using:
lock tables [table] write
at point other sessions blocked when trying read table, until table unlocked.
unlock tables
now blocking stop.
is possible in sql server?
begin transaction select * tablename (tablockx) /* stuff here */ commit transaction
tablockx
obtain exclusive lock on table , other users not able read or update data until commit transaction yourself.
Comments
Post a Comment