SQL Server扩展存储过程实现远程备份与恢复
本文通过实例解析了 SQL Server 数据库 扩展 存储 过程 , 实现 远程 备份 与 恢复 的方法和步骤…… 实例说明: 环境:win2k+sqlserver 2K+查询分析器 SQL SERVER服务实例名称:mainserver 需要 备份 的数据库名称: msdb 本地机器名称(Client端):david 本地
本文通过实例解析了 SQL Server 数据库扩展存储过程,实现远程备份与恢复的方法和步骤……
实例说明:
- 环境:win2k+sqlserver 2K+查询分析器
- SQL SERVER服务实例名称:mainserver
- 需要备份的数据库名称: msdb
- 本地机器名称(Client端):david
- 本地用户:zf 密码:123
- 本地域名:domain
- 本地提供备份需求的文件夹:e: est
第一步: 建立共享文件夹
在程序代码中调用(或者CMD窗口) net share test=e: est
或者用NetShareAdd这个API
简要说明:
net share: 是WINDOWS内部的网络命令。
作用:建立本地的共享资源,显示当前计算机的共享资源信息。
语法:参见 net share /?
第二步: 建立共享信用关系
master..xp_cmdshell 'net use \david est 123 /user:domainzf'
简要说明:
1:xp_cmdshell :是SQLSERVER的扩展存储过程。
作用,以操作系统命令行解释器的方式执行给定的命令字符串,
并以文本行方式返回任何输出。
语法:参见SQLSERVER联机帮助
2:net use: 是WINDOWS内部的网络命令。
作用,将计算机与共享资源连接或断开,或者显示关于计算机
连接的信息。该命令还控制持久网络连接。
语法:参见 net use /?
第三步:备份数据库
backup database msdb to disk='\david estmsdb.bak'
这个不需要说明吧,语法参见SQLSERVER联机帮助
第四步: 删除共享文件夹
在程序代码中调用(或者CMD窗口) net share test /delete
或者用NetShareDel这个API
结果:
已处理 1376 页,这些页属于数据库 'msdb' 的文件 'MSDBData'(位于文件 1 上)。
已处理 1 页,这些页属于数据库 'msdb' 的文件 'MSDBLog'(位于文件 1 上)。
BACKUP DATABASE 操作成功地处理了 1377 页,花费了 3.653 秒(3.086 MB/秒)。
这样mainserver服务器上的msdb就备份到了david机器的E: estmsdb.bak文件了,使用起来很简单吧?恢复数据库操作也是一样,只要将第三个步骤的语句改为'restore database msdb from disk='\david estmsdb.bak'就可以啦。。你看完了也可以试试呀?!(最简单的测试工具查询分析器+CMD窗口)
备注:xp_cmdshell 这个扩展存储过程只能SA级别的用户调用,而且是SQL Server的安全隐患之一,许多DBA都喜欢将其删除或者禁用,所以开发人员使用时要倍加小心哦。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

To extend PHP function functionality, you can use extensions and third-party modules. Extensions provide additional functions and classes that can be installed and enabled through the pecl package manager. Third-party modules provide specific functionality and can be installed through the Composer package manager. Practical examples include using extensions to parse complex JSON data and using modules to validate data.

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

In today's software development field, Golang (Go language), as an efficient, concise and highly concurrency programming language, is increasingly favored by developers. Its rich standard library and efficient concurrency features make it a high-profile choice in the field of game development. This article will explore how to use Golang for game development and demonstrate its powerful possibilities through specific code examples. 1. Golang’s advantages in game development. As a statically typed language, Golang is used in building large-scale game systems.

Git is a fast, reliable, and adaptable distributed version control system. It is designed to support distributed, non-linear workflows, making it ideal for software development teams of all sizes. Each Git working directory is an independent repository with a complete history of all changes and the ability to track versions even without network access or a central server. GitHub is a Git repository hosted on the cloud that provides all the features of distributed revision control. GitHub is a Git repository hosted on the cloud. Unlike Git which is a CLI tool, GitHub has a web-based graphical user interface. It is used for version control, which involves collaborating with other developers and tracking changes to scripts and
