How do I pass timeout parameter to SQL Database Engine

sql-server, sql-server-2005, t-sql

Solution

By default, the SqlCommand.CommandTimeout is set to 30 seconds. You can assign a longer duration before executing the query, or set to 0 for no timeout. (if the question refers to .Net programming)

Problem

I'm running a query that is timing out for first two times and returning results on the third time. How do I tell SQL Server to wait until the query is completed instead of timing out?

Original source