I am moving a SQL database from my C:\ to a Server and I'm a little new at this. I use Openrowset
and Opendatasource
to get data from Excel, Access, and CSV files but now it only works with a fixed drive (C:\ or E:). I am trying to use xp_CmdShell
to map the drive and here is what I get:
First, I ran this:
exec sp_configure 'xp_cmdshell', 1;
reconfigure
Then this:
exec xp_cmdshell 'net use G: \\172.16.0.32\Finance'
and got
The command completed successfully. NULL NULL
Then I run:
exec xp_cmdshell 'net use'
and get:
New connections will be remembered. NULL NULL Status Local
Remote Network NULL ------------------------------------------------------------------------------- OK G: \172.16.0.32\Finance Microsoft Windows Network The command completed successfully. NULL NULL
But I run this and get an error:
exec xp_cmdshell 'Dir G:'
An unexpected network error occurred. NULL
If anyone can help it would be huge!
Update: I deleted the drive and remapped it, rebooted the server and restarted the service
exec xp_cmdshell 'net use G: /delete' exec xp_cmdshell 'net use G: \172.16.0.32\Finance'
Then I got this:
exec xp_cmdshell 'Dir G:'
Volume in drive G is FileSharing1 Volume Serial Number is 20E1-DEF3 NULL Directory of G:\ NULL 06/22/2017 08:56 AM . 06/22/2017 08:56 AM .. 09/20/2017 09:37 AM
IMA Utilization Reports 03/09/2017 06:36 PM
Microsotf SQL Server 2014 02/15/2017 06:22 PM
Wellcare-Apixio Project 0 File(s) 0 bytes 5 Dir(s) 722,791,567,360 bytes free NULL
After all that my OPENROWSET Query still does not work