SQl Server I need to fix the error of “Timeout exp

2019-08-16 05:17发布

问题:

I know it's been asked a bunch of times but I can't seem to get the fixes I've read to solve my issue. I'm getting the SQL Server error that "the timeout period elapsed prior to completion of the operation or the server is not responding." I changed the setting under Tools>Options>Designers>"Override connection string time- out value" to 120 seconds as per this posting, but... it still times out after 30 seconds. I'm accessing the database from visual studio, working directly with it, and not with ado in client code. I'm open to suggestions... here's the query btw:

SELECT Symbol FROM tblSymbolsMain WHERE ((SELECT dbo.LatestDateInDailyPricingVolBySymbol(tblSymbolsMain.Symbol) AS Expr1) < dbo.RecentTradingDateByNumber(5))

In a nutshell, the goal is to return all stock symbols from a main symbols table that don't have a daily pricing data point in the pricing table for at least 5 trading days.

As always thanks in advance..

回答1:

The code doesnt appear to be correct ... you have ...WHERE (SELECT...) WHERE what?

Are you sure you are not after

SELECT MyCols FROM MyTable WHERE ID IN (...)

OR

SELECT MyCols FROM MyTable WHERE ID NOT IN (...)

Where (...) represents another select returning some sort of ID.

Otherwise of course you'd get a timeout. That select may return a count and WHERE 1 can go on and on and on...