我写了一个脚本,需要很长时间才能运行。 它看起来像这样:
set nocount on
select 1
GO
select 2
GO
select 1
GO
select 2
GO
并且这种情况会持续很长时间。在SSMS中,完成需要1分钟以上,而在SQLCMD中则需要不超过1秒。 sqlcmd总是比SSMS快得多吗?
这是传递给sqlcmd的命令:
-i filepath\test.sql -v FilePath = "filepath\test2.sql" -r -S servername -d dbname -U username -P password
test.sql包含:
SET NOCOUNT ON
:r $(FilePath)
GO
因为两次设置nocount似乎没有问题,而且这个程序运行着数百个脚本,其中许多脚本没有nocount。
sqlcmd版本:2005.90.5000
SSMS版本:2011.110.3000