Wednesday, February 23, 2022

Map a drive in SQL SERVER 2014

Tags

 

Why map a drive in SQL server 2014?

1.Easy to make a backup on remote Nas server or Synology.

2.Easy to restore database.

3.keep database on NAS or Synology.

After we run Query below  you need to restart service SQL MSSQL in Service management.

Then log in  SQL Server 2014 with  sa user.Then you will see the drive that you map.


Map drive in sql server 2014

Use Master

GO

EXEC master.dbo.sp_configure 'show advanced options', 1

RECONFIGURE WITH OVERRIDE

GO

EXEC master.dbo.sp_configure 'xp_cmdshell', 1

RECONFIGURE WITH OVERRIDE

GO

EXEC xp_cmdshell 'net use Z: \\10.0.0.10\e /user:domain\userName "password"'

EXEC XP_CMDSHELL 'net use Z:  \\10.11.0.10\database\SQL /USER:admin  "123456789"';

EXEC XP_CMDSHELL 'Dir Z:'

        Disable map network drive in sql server

EXEC XP_CMDSHELL 'net use Z: /delete'

នេះជាព័ត៌មានថ្មីបំផុត