
执行SQL语句。 SQL SERVER2000,2008 测试通过)
中断除了自己外的连接:
declare @sql varchar(100)
while 1=1
begin
select top 1 @sql = 'kill '+cast(spid as varchar(3))from master..sysprocesses
where spid > 50 and spid <> @@spid
if @@rowcount = 0
break
exec(@sql)
end
如果只要需要中断某一个数据库的,请加条件
and dbid=db_id('your dbname')
打开就是调用open方法,关闭就是调用close方法,例如:
(1)首先建立连接:sqlconnectionconn=newsqlconnection()。
(2)然后打开连接:conn.open()。中间就是你处理的事情的代码,处理完后看。
(3)最后就是关闭连接:conn.close()。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)