# SQL Command Timeout

**URL:** <https://forum.uipath.com/t/sql-command-timeout/10141>\
**Category:** Help\
**Tags:** database, activities\
**Created:** [August 21, 2017, 5:29pm UTC](https://forum.uipath.com/t/sql-command-timeout/10141 "2017-08-21T17:29:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Medical\_1234](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/medical_1234/32/3799_2.png) [@Medical\_1234](https://forum.uipath.com/u/Medical_1234)\
**Post date:** [August 21, 2017, 5:29pm UTC](https://forum.uipath.com/t/sql-command-timeout/10141/1 "2017-08-21T17:29:01Z")

</div>

We are receiving the following Uipath error when we run a stored procedure. It only occurs when the result set takes over 30 seconds to return. We have checked SQL timeout settings, execution etc. and they are set as expected.

Error and stack trace below.

E:\CQRbot\Bots\>ECHO — SAMPLE Change the atMonthOffset argument to the number o  
f days from today to June 5  
— SAMPLE Change the atMonthOffset argument to the number of days from today to  
June 5

E:\CQRbot\Bots\>“C:\Users\pbauerlein\AppData\Local\UiPath\app-17.1.6414\UiRobot.e  
xe” /file:“E:\CQRbot\XAML\Qbot\_CQR.xaml” /input:“{‘atExcelFile’:‘AOSM(QUA)102538  
.xlsx’,‘atProcessID’:‘E’,‘atPeriod’:‘Q’,‘atMonthOffset’:-74}”  
XAML System.Data.SqlClient.SqlException: Timeout expired. The timeout period el  
apsed prior to completion of the operation or the server is not responding. —\>  
System.ComponentModel.Win32Exception: The wait operation timed out  
— End of inner exception stack trace —

Server stack trace:  
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolea  
n breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception , Boolean breakConnection, Action`1 wrapCloseInAction)  
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObj  
ect stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)  
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand  
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler,  
TdsParserStateObject stateObj, Boolean& dataReady)  
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName,  
Boolean async, Int32 timeout, Boolean asyncWrite)  
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSou  
rce`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at UiPath.Database.DatabaseConnection.Execute(String sql, Dictionary`2 parame  
ters, CommandType commandType)  
at UiPath.Database.Activities.ExecuteNonQuery.\<\>c\_\_DisplayClass34\_0.b\_\_0()  
at System.Runtime.Remoting.Messaging.StackBuilderSink.\_PrivateProcessMessage(  
IntPtr md, Object args, Object server, Object& outArgs)  
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMe  
ssage msg, IMessageSink replySink)

Exception rethrown at [0]:  
at UiPath.Database.Activities.ExecuteNonQuery.EndExecute(AsyncCodeActivityCon  
text context, IAsyncResult result)  
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.F  
inishExecution(AsyncCodeActivityContext context, IAsyncResult result)  
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.Complete  
AsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager boo  
kmarkManager)  
E:\CQRbot\Bots\>PAUSE  
Press any key to continue . . .

---

<div class="post-metadata">

**Author:** ![ovi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ovi/32/21072_2.png) [@ovi](https://forum.uipath.com/u/ovi)\
**Post date:** [August 21, 2017, 8:49pm UTC](https://forum.uipath.com/t/sql-command-timeout/10141/2 "2017-08-21T20:49:31Z")

</div>

Hi Thom!  
Please check this post:

> [@Timeout while executing database query](https://forum.uipath.com/t/timeout-while-executing-database-query/824/3):
>
> Hello! You just have to add ;Connect Timeout=5000 on the Connection String. The Timeout must be in Milliseconds. Regards!

---

<div class="post-metadata">

**Author:** ![nicolas.roussel](https://avatars.discourse-cdn.com/v4/letter/n/57b2e6/32.png) [@nicolas.roussel](https://forum.uipath.com/u/nicolas.roussel)\
**Post date:** [September 26, 2017, 12:47pm UTC](https://forum.uipath.com/t/sql-command-timeout/10141/3 "2017-09-26T12:47:22Z")

</div>

Connect Timeout is only for the connection.  
In this case, this is command Timeout that should be increase, but it is not possible in the connection string nor in the Execute Query activity…

---

<div class="post-metadata">

**Author:** ![Madhavi\_Jaiswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/madhavi_jaiswal/32/20495_2.png) [@Madhavi\_Jaiswal](https://forum.uipath.com/u/Madhavi_Jaiswal)\
**Post date:** [February 14, 2018, 8:58am UTC](https://forum.uipath.com/t/sql-command-timeout/10141/4 "2018-02-14T08:58:14Z")

</div>

You will have to specify the command time out period explicitly for the SPs running for long time.  
Use below code to build the connection and run a stored proc.  
[CallStoredProcedure.xaml](https://global.discourse-cdn.com/uipath/original/2X/3/3948c49eaf5059702567b091969bd5acb79ef9e2.xaml) (10.6 KB)

---

<div class="post-metadata">

**Author:** ![dulanthag](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dulanthag/32/177297_2.png) [@dulanthag](https://forum.uipath.com/u/dulanthag)\
**Post date:** [June 29, 2022, 7:43am UTC](https://forum.uipath.com/t/sql-command-timeout/10141/5 "2022-06-29T07:43:52Z")

</div>

![Capture](https://global.discourse-cdn.com/uipath/original/4X/a/7/6/a7614524e72f848d6beea8cef38ffd5e9055b7fb.jpeg)

Timeout property not working for Execute Query activity…Can anyone help…
