Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Return error of a timeouted server

Author  Topic 

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-10-22 : 04:51:59
I am trying to get the timeout expired error from an EXEC.
From what i see it will only return 0, whether there is a timeout or not.


USE [VISTAHO]
GO
/****** Object: StoredProcedure [dbo].[ZZ_execRemoteProcedure] Script Date: 21/10/2014 5:43:52 µµ ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER PROCEDURE [dbo].[ZZ_execRemoteProcedure]
@Server VARCHAR(20),
@Procedure VARCHAR(50),
@Parameters VARCHAR(1000),
@RemoteTable VARCHAR(50),
@LocalTable VARCHAR(50)

AS
BEGIN
declare @ExecError INT
CREATE TABLE #ErrFile (ExecError INT)

EXEC(
'EXEC ' + @Server + '.VTA.dbo.' + @Procedure + ' ' + @Parameters + '
INSERT INTO ' + @LocalTable + '
SELECT * from ' + @Server + '.VTA.dbo.' + @RemoteTable
+ ' INSERT #ErrFile VALUES(@@ERROR)'
)

SET @ExecError = (SELECT * FROM #ErrFile)


IF @ExecError is null
BEGIN
return 0
End
ELSE
return @ExecError


END



But i get 0 all the time.
Any help?
thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-10-22 : 12:13:51
You need to catch the timeout in your application as SQL doesn't cause the timeout. It's the application's query timeout setting that determines the timeout.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-10-24 : 18:52:59
Ahhm, so you mean the @Procedure ?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-10-25 : 17:26:53
I mean you need to edit your application, not the stored procedure, and catch the timeout there. SQL isn't timing it out, your application is due to the query timeout setting.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-10-27 : 03:47:11
Hi, i really do not understand what you mean by "application".
I run a stored procedure on sql management studio and it times out.
Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-10-27 : 11:48:15
By default, Management Studio does not timeout, so you must've made a configuration change. Revert it. The default is 0, which means let it run indefinitely.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-10-27 : 20:16:26
Oh, yes, it is set to 1200 if i recall correctly but i would like to capture a timeout if that limit is exceeded.
Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-10-31 : 13:22:09
We've gone in a circle. You need to capture it in the application. And by application, I don't mean SSMS.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-10-31 : 19:16:56
Sorry for this but i haven't been in a situation to capture a timeout on the SQL server as i am mostly in Web Development.
So to get this straight, i cannot capture it in a stored procedure and i must capture this somehow in SSMS?
If so, then there is no way to get the timeout in a stored procedure and by that i mean with t-sql error methods.Correct?
Thanks,
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-11-03 : 12:25:49
You don't capture it in SSMS. You are writing SQL queries/stored procedures for an application (not SSMS), right? Or someone is, right? It's in that application that you catch and handle timeouts.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-11-11 : 11:03:06
Hi, no actually it's an SQL JOB that is running on SQL SERVER AGENT.
Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-11-11 : 12:12:26
quote:
Originally posted by sapator

Hi, no actually it's an SQL JOB that is running on SQL SERVER AGENT.
Thanks.



How are you getting it to timeout then? SQL Agent jobs can run indefinitely.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-11-12 : 18:39:15
Hi. Yes we can leave it but since it's getting data from different locations and these locations are been used constantly it fills the line (as it get's remote data as you can see on the first post). So there is a timeout limit that we want, if reached, to do some manipulations.
Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-11-12 : 18:48:32
How are you going to cause it to timeout? I don't think you can do this unless you use SQLCLR where you can impose a timeout.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-11-13 : 18:32:53
We have it run on the SQL job and the timeout is set to 1200 if i remember correctly. I don't do anything fancy. It's the SQL timeout limit reached.
Am i missing something here?
Thanks.
Go to Top of Page
   

- Advertisement -