How do I set a SQL Server script's timeout from within the script?

我的未来我决定 提交于 2019-11-29 06:37:12
sqlcmd -t {n}

Where {n} must be a number between 0 and 65535.

Note that your question is a bit misleading since the server has no concept of a timeout and therefore you cannot set the timeout within your script.

In your context the timeout is enforced by sqlcmd

Your solution - Add GO every 100 or 150 lines

http://www.red-gate.com/MessageBoard/viewtopic.php?t=8109

I think there is no concept of timeout within a SQL script on SQL Server. You have to set the timeout in the calling layer / client.

According to this MSDN article you could try to increase the timeout this way:

exec sp_configure 'remote query timeout', 0 
go 
reconfigure with override 
go 

"Use the remote query timeout option to specify how long, in seconds, a remote operation can take before Microsoft SQL Server times out. The default is 600, which allows a 10-minute wait. This value applies to an outgoing connection initiated by the Database Engine as a remote query. This value has no effect on queries received by the Database Engine."

P.S.: By 300 MB you mean the resulting file is 300 MB? I don't hope that the script file itself is 300 MB. That would be a world record. ;-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!