LegalEagle
LegalEagle

Reputation: 97

SQL Query Runs Forever

SELECT * 
FROM PaymentBatchItems
WHERE CreatedDate = '2016-11-03';

This query should return about 6 rows. I have watched it run for over 7 minutes and still running. I suspect there may be some inconsistent data in there, however I can't query the table to find out.

I ran

DBCC CHECKTABLE(PaymentBatchItems) WITH PHYSICAL_ONLY 

and it returned no errors. Also tried

DBCC CHECKTABLE(PaymentBatchItems)

and it also returned no errors.

Any ideas how I can find what's hanging up my very simple query?

Upvotes: 0

Views: 7338

Answers (2)

LegalEagle
LegalEagle

Reputation: 97

FOUND THE ISSUE!

When I was closing out my tabs at the end of the day, I discovered there were uncommitted transactions on one of the other server tabs. Rolled back the transactions and was able to query the table without issue.

Thanks everyone for your help. Sorry for the newbie error!

Upvotes: 4

Eliseo
Eliseo

Reputation: 416

Look at the table structure, most likely PaymentBatchItems has a varbinary/blob column which might contain a lot of data. Instead of returning * try to return only one column.

Also use "top" for example

select top(100) * from ...

Upvotes: 0

Related Questions