Map Network Drive using Start up Stored Procedure
In the Data World, We always have the situation to take backup in network drive.
Problem:-
You are manually mapping network, whenever restarting Window Server or SQL Server. If we forget to map the network drive, next day there is a problem in backup or restore.
Solution:-
Start Up stored procedure useful to overcome the manually mapping network drive problem.
Startup Stored Procedure
Start Up stored procedure useful for autoexecution. A stored procedure set to autoexecution every time an instance of SQL Server is started.
You may ask..? How this Stored Procedure will help to map network drive.
Net use
Net Use is the command used to connect a computer to or disconnect a computer from shared resource; the command also controls persistent net connections.
net use <driver letter> \<servername>\sharename> /user:<username> <password>
xp_cmdshell
Enable xp_cmdshell to use net use command in SQL Server.
Net use command to connect the network drive manually.
Step #1.Stored procedure with net use command
Step #2.Map the Stored Procedure to startup.
Now restart SQL or window server to check the network drive.
I hope the article helpful to you!