[dba-VB] C# SQLCommand.Timeout

jwcolby jwcolby at colbyconsulting.com
Mon Nov 30 13:55:11 CST 2009


Any words of wisdom on setting the command.Timeout property?  I have stored procedures that execute 
instantly, and others that can take an hour or more (large appends).

How can I discover how long a stored procedure takes to run so that I can set this property 
dynamically?  As an example I have cases where I am appending 65 million rows into a table of 6 
fields.  This can take a long time (at the very least perhaps 20 minutes) but if I could get a 
"RecordsAffected" count for such queries as well as the time it took to execute, then I could start 
to discover that it takes "X seconds / million" records, and set the timeout to a reasonable value 
based on the records to be appended.

This doesn't have to be any exact time value.  I assume a simple pair of time variables, then "stop 
time - start time"?

Or should I just discover worst case and set it to that?
-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-VB mailing list