Yes, you are correct, Erland.
That's what I meant, when I ran the query on the VB.NET program I got
the timeout error, even though the same query will run fine most of
the times.
>> As for the cause, the most likely reason at hand, I would say is blocking.
That's what I thought also.
So, even though the query is a SELECT statement (joining a few
tables), something else can block the SELECT statement to run ?
Will it be another SELECT statement or INSERT that's blocking it ?
How can I find out about it ?
Is it by running this query ?
SELECT
database_id,sql_handle,session_id ,status ,blocking_session_id,wait_type ,wait_time ,wait_resource,transaction_id
FROM sys.dm_exec_requests WHERE status = N'suspended';
If that's the way, the problem is when I run it most of the time, it
returns nothing.
Thanks, Erland.
On Feb 15, 4:27*pm, Erland Sommarskog <esq...@sommarskog.se> wrote:
> fniles (fiefie.ni...@gmail.com) writes:
> > We are using SQL Server 2005 and VB.NET 2008.
> > We have a view that is called by the application every minute.
> > The view is doing a SELECT of 2 more views and a table.
> > When I run the view on the SQL Server Management Studio, it runs for 2
> > seconds.
> > Most of the time when the view is run from the VB.NET program it runs
> > as fast.
> > But, about once or twice a day in the program the view will timed out
> > (error "Timeout expired. *The timeout period elapsed prior to
> > completion of the operation or the server is not responding.), even
> > after I set the command time out to 45 seconds (which is a lot longer
> > than the 2 seconds it takes to run it on the SSMS).
>
> > Why would the same SELECT view runs fast most of the time, but very
> > slow once or twice a day ?
>
> First of all, views cannot time out. A view is just a query. That's
> all there is. There is no execution plan or anything saved for the view.
> And the time out happens in the client application, that grows tired of
> waiting.
>
> As for the cause, the most likely reason at hand, I would say is blocking..
>
> --
> Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
>
> Links for SQL Server Books Online:
> SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> SQL 2005:http://msdn.microsoft.com/en-us/sqls...bb895970.aspx- Hide quoted text -
>
> - Show quoted text -