execsp_configure'show advanced options', 1
execsp_configure'user connections', 100
第一句用以表示显示sp_configure 系统存储过程高级选项,使用userconnections 时,要求show advanced options 值为1。
第二句配置最大连接数为100,0 表示不限制,但不表示无限,后面将谈谈。
也可以在企业管理器中配置,在企业管理器中,可以在实例上点右键->“属性”->“连接”里面更改。
需要重新启动SQL Server,该值才会生效。
@@max_connections
select@@max_connections
它总是返回32767,它并不是指上面设置的userconnections,实际上它表示userconnections 最大可设置为多少。由于它的最大值是32767,那么userconnections 为0 时,最大连接数也就是32767 了,并不是无限。
默认情况下userconnections 值是0,也就是说默认情况下SQL Server 的最大连接数是32767。
获得当前设置的最大连接数:
selectvaluefrom master.dbo.sysconfigureswhere[config]=103