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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -