本文转自:https://mytechmantra.com/LearnSQLServer/Configure-Network-Drive-Visible-for-SQL-Server-During-Backup-and-Restore-Using-SSMS/

Introduction

Most of the Development and Test Database Servers will not have enough disk space to store both the database and backup files in order to perform the periodic database refreshes. In such scenarios, the best option will be to store the database backup files in a mapped network drive and perform the database restores from the mapped drive. However, things can become really complicated when the developer tries to restore the database using SSMS and they couldn't locate the respective mapped drive under Locate Backup File window as shown in the snippet below.

In SQL Server Management Studio, if you try to browse the backup files, you will only see the local drives available to SQL Server Database Engine. In this article we will take a look at the approach on How to Configure SQL Server to Display Network Path Visible to SSMS to Perform Database Backup or Restore Commands.

How to Map a Network Drive

By default, a network share is not visible to SQL Server Database Engine. Hence, you will have to mark Network Share as a Mapped Network Drive using the using the Map Network Drive feature of the Operating System. Refer the below screenshots which highlights How to Create a Mapped Network Drive.

Once the Network Drive is mapped successfully the next Step will be to identify the network drive within SQL Server. This can be achieved by using XP_CMDSHELL command. For more information, see How to Enable and Disable XP_CMDSHELL command in SQL Server.

Recommendation: You can't fix an SQL Server Performance Issues until you can identify it. Download Fully Functional Database Performance Analyzer and see how it will pinpoint SQL Server Performance Issue! Become the STAR Performer!

How to Map Network Drive in SQL Server

In the below script replace Drive Letter and Share Path with values in your environment to Map Network Drive in SQL Server.

EXEC XP_CMDSHELL 'net use Z: \\RemoteServerName\ShareName'

How to Verify Mapped Network Drive Mapping in SQL Server

Execute the below query by replacing the Dirve Letter with the Drive Letter which you have provided in your environment.

EXEC XP_CMDSHELL 'Dir Z:'

Once you have executed the above script successfully you will be to see "Z Drive" under Locate Backup File as shown in the below snippet.

How to Delete Mapped Network Drive Mapping in SQL Server

Execute the below TSQL code to Delete the Mapped Network Drive from SQL Server.

EXEC XP_CMDSHELL 'net use Z: /delete'

Action Item

    • You can very well provide the full network location of the file in "File Name" field of "Locate Backup File" window. The approach mentioned in this article is only required if you wish to perform backup or restore using SQL Server Management Studio.
    • DBAs or Developers can very well backup or restore database from Network Share without Mapping the drive. This is only required if you wish to perform backup or restore using SQL Server Management Studio.
    • Once you have completed the Backup or Restore as a Best Practice on should disable XP_CMDSHELL in SQL Server. For more information see, How to Enable and Disable XP_CMDSHELL command in SQL Server
    • Learn more about SQL Server Security Best Practices.

[转]Configure Network Drive Visible for SQL Server During Backup and Restore Using SSMS的更多相关文章

  1. SQL Server Database Backup and Restore in C#

    SQL Server Database Backup and Restore in C# Syed Noman Ali Shah,                          7 Feb 201 ...

  2. SQL Server 2014 Backup Encryption

    转载自: Microsoft MVP Award Program Blog 来源:Microsoft MVP Award Program Blog 的博客:https://blogs.msdn.mic ...

  3. SQL Server在本地计算机上用SSMS(SQL Server Management Studio)登录不上,错误消息:(Microsoft SQL Server, Error: 18456)

    今天遇到了一个奇怪的问题,公司目前在SQL Server上都采用AD域账号登录,由于账号人数众多,所以我们建立了一个AD Group(域组),将大家的AD账号加入了这个AD Group,然后我们将这个 ...

  4. SQL SERVER备份数据库文件(使用SSMS)

    微软的SQL SERVER是市面占有率比较大的数据库,在平时的使用与维护中,备份数据是一件十分重要的! 备份操作,用微软自带的ssms(SQL Server Management Studio)工具即 ...

  5. 转载:Restore SQL Server database and overwrite existing database

    转载自:https://www.mssqltips.com/sqlservertutorial/121/restore-sql-server-database-and-overwrite-existi ...

  6. Ubuntu上配置SQL Server Always On Availability Group(Configure Always On Availability Group for SQL Server on Ubuntu)

    下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭 ...

  7. Configure Always On Availability Group for SQL Server on RHEL——Red Hat Enterprise Linux上配置SQL Server Always On Availability Group

    下面简单介绍一下如何在Red Hat Enterprise Linux上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的 ...

  8. Configure Always On Availability Group for SQL Server on Ubuntu——Ubuntu上配置SQL Server Always On Availability Group

    下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭 ...

  9. Configure Always On Availability Group for SQL Server on Ubuntu

    下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭 ...

随机推荐

  1. subprocess.Popen 运行windows命令出现“句柄无效”报错的解决方法

    在框架开发中遇到 subprocess执行多了,就会好句柄无效的问题,终于找到解决方案:如下,修改subprocess中的一点代码就好,也不知道这是不是Python 的bug因为,Python27时没 ...

  2. ABP框架踩坑记录

    ABP框架踩坑记录 ASP.NET Boilerplate是一个专用于现代Web应用程序的通用应用程序框架. 它使用了你已经熟悉的工具,并根据它们实现最佳实践. 文章目录 使用MySQL 配置User ...

  3. 前端入门CSS(2)

    参考: https://www.cnblogs.com/liwenzhou/p/7999532.html 背景属性 /*背景颜色*/background-color: red; /*背景图片*/ ba ...

  4. 比特、字节、K

    比特(bit) 比特,计算机专业术语,是信息量单位,由英文BIT音译而来.BIT为Binary digit(二进制数)位的缩写.二进制数的一位所包含的信息就是一比特,如二进制数0100就是4比特. 字 ...

  5. shell 多线程

    不熟悉 io 重定向的童鞋,先学习一下相关知识 http://www.linuxplus.org/kb/io-redirection.html 下面是简单代码 #!/bin/bash tmpfile= ...

  6. 安装gitlab

    安装源: git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-10-stable gitlab 安装文档: 在github上:gitl ...

  7. 00-python概述。

    人生苦短,我用Python. -发展历史: - 1989年,由Guido van Rossum开始开发, - 1991年,发布第一个公开发行版,第一个Python编译器(同时也是解释器)诞生. - 2 ...

  8. JAVA线程本地变量ThreadLocal和私有变量的区别

    ThreadLocal并不是一个Thread,而是Thread的局部变量,也许把它命名为ThreadLocalVariable更容易让人理解一些. 所以,在Java中编写线程局部变量的代码相对来说要笨 ...

  9. 【GDKOI2017】 两个胖子萌萌哒 小学奥数题

    题目大意:给你一个$n\times m$的网格,你要在这个网格上画三角形. 三角形的顶点只能在网格的整点上,且至少有一条边平行于$x$或$y$轴,且三角形面积为整数.问你能画多少个不同的三角形. 两个 ...

  10. NOIP上机测试注意事项

    由于近期模拟题原地**次数较多,故写一篇警示文 1,头文件 1.1正式比赛中,反正我不敢用bits/stdc++.h. 1.2正式比赛中,建议打出以下十个库 #include<iostream& ...