Make visible network backup in MS SQL

Problem:

How to make visible network backup in MS SQL

Solution:

Run this commands:

First one was to identify that network drive in SQL Server, you will use the xp_cmdshell command. Before that, you need to make sure that the xp_cmdshell command is enabled in your SQL instance, as it is disabled by default. Use the sp_configure command to enable it as shown below:

EXEC sp_configure ‘show advanced options’, 1;
GO
RECONFIGURE;
GO

EXEC sp_configure ‘xp_cmdshell’,1
GO
RECONFIGURE
GO

Then,

Now define that share drive for SQL with the xp_cmdshell command as follows:

EXEC XP_CMDSHELL ‘net use H: \\RemoteServerName\ShareName’

It should now be mapped. In order to verify the new drive, you can use the below command that will show you all files in that newly mapped drive:

EXEC XP_CMDSHELL ‘Dir H:’

To Delete the network  backup path in MS SQL

Optionally you can delete that path after you finish using the below command:

EXEC XP_CMDSHELL ‘net use H: /delete’ /pre>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s