I need to be able to lock a table in SQL Server while doing some work. The lock needs to block other sessions from reading the table. When the work is complete the table needs to be unlocked.
In MySQL I have done this by using:
LOCK TABLES [table] WRITE
At this point other sessions will be blocked when trying read from the table, until the table is unlocked.
UNLOCK TABLES
Now the blocking will stop.
Is this possible in SQL Server?