Mapping Drives To Your SQL Script NET USE

658 views Asked by At

I do a lot of work with the file system in my SQL scripts. After a lot of effort, the only way I'm able to get all my network shares and NAS devices to be available to my SQL scripts is to start the script off with a "Net Use" command to map a drive letter.

I find this annoying to work with and sometimes unreliable.

I use something like this at the top of my scripts / stored procedures:

exec xp_cmdShell 'net use S: \\nas1\Data pass1234 /user:administrator /PERSISTENT:YES'

After I execute this, then the S:\ drive is available for me to work with.

Does anyone have a more elegant solution to this that is easier to set up?

Side note: I don't have a domain controller.

0

There are 0 answers