现在我要作数据库远程备份,与恢复,恢复时,希望先把远程SQL服务先停止,再启动。可是停止后我不知道如何在Delphi里启动远程SQL服务?
解决方案 »
- Memo 组件中的文字如何锁定呢
- cxgrid如何框选表中的数据
- 调用DLL时正确,但退出时提示错误
- 如何得到一个字符串的16进制编码?
- 找不到DAQDeviceLib_TLB.dcu ?
- 快速生成报表控件,供开源代码,大家拿去改吧,我写的,比较实用。
- 请问这个功能如何实现:一个程序每天到上午9点就提示一个信息。
- 怎样提出HTML文件中的一块到一个字符串?
- 如何使用BroadcastSystemMessage在不同程序间发送结构。
- 用intraweb做的Web页一刷新就谈出一个对话框,如何去处?
- 求救:把EXCEL中的记录,一条条导入到已经存在表的SQL SERVER2000中,
- 请教几个多层开发技术的术语,高手请进
/*
关闭用户打开的进程处理
*/
use master
goif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_killspid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_killspid]
GOcreate proc p_killspid
@dbname varchar(200) --要关闭进程的数据库名
as
declare @sql nvarchar(500)
declare @spid nvarchar(20) declare #tb cursor for
select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname)
open #tb
fetch next from #tb into @spid
while @@fetch_status=0
begin
exec('kill '+@spid)
fetch next from #tb into @spid
end
close #tb
deallocate #tb
go--用法
exec p_killspid '数据库名'
=======================================================
用的delphi执行上面的脚本之后,在使用restore命令恢复,不用关掉sql服务
还有你上面的脚本是什么意思,有什么作用,谢谢
select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname) --定义个游标遍历数据库所有服务进程--------------------------------------- open #tb
fetch next from #tb into @spid
while @@fetch_status=0
begin
exec('kill '+@spid)
fetch next from #tb into @spid
end
close #tb--逐个将进程kill掉,这个个时候所有的客户端都强制与服务器断开连接,启动restor 命令的时候就不回报数据库在使用的错误了===========================================可以的,你再试试