Search code examples
sqlsql-server-2008-express

Simplest SQL query never returns


I have a SQL query that is quite simply select * from tblOrders where customerID = 5000but it never returns. I waited 10 minutes and gave up.

The weirdest thing is that other queries on the same DB, but on another table, works fine. Removing the where-clause doesn't help either, so it seems like the table is somehow not responding. It's about 30000 lines, so it's not the biggest table either.

I'm using MS SQL SMS 2008 Express against a SQL Server 2008 express running on a remote server.


Solution

  • It sounds like your table is locked

    run this query to see what locks are held against it.

    USE master;
    GO
    EXEC sp_lock;
    GO
    

    but table locking is a whole mindfield of its own here is some info in the sp_lock system stored proc http://msdn.microsoft.com/en-us/library/ms187749.aspx

    when you find the lock you can kill it

    KILL { session ID | UOW } [ WITH STATUSONLY ] 
    

    http://msdn.microsoft.com/en-us/library/ms173730.aspx