0

I need to know if there is any way to find out if a table is being queried by some other process in SQL Server.

I am trying to Merge Empty Partitions on a table, and that table is being queried by many process. So, i need to check if the table is being read/insert by other process,if yes than my merge operation will not proceed. Because if it runs then it gets locked and fails over time. Due to which sometimes i run out of partitions or i have to run it manually.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Nausif
  • 400
  • 1
  • 6
  • 17

1 Answers1

1

How would possibly help knowing would querying if the table was not used? Think about it, any information you get ('no query') is already obsolete by the time you act. This is not the way to go, the way to go is simply to reduce the lock timeout and attempt to do your operation:

SET LOCK_TIMEOUT 1;
ALTER PARTITION FUNCTION ... MERGE ...
Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569