Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am trying to map another server by giving the command

EXEC xp_cmdshell 'NET USE H:\568.256.8.358\backup_147 1234abc /USER:cranew /PERSISTENT:yes'

I got an error with this network path not found

But I am able to map another server manually.

Please do help me in sorting out this.

share|improve this question
    
Hello, to avoid being flagged down or having your question deleted by the mods, please provide more information. How are you trying to connect to another server by using SQL Server Management Studio exactly? Are you using powershell? XP_CMDSHELL? Your NET USE command is totally wrong as well. I don't see how that would work anywhere, inside or outside of SQL Server. You need 2 backslashes (\) and a folder for it to work. –  Ali Razeghi Oct 25 '12 at 5:30
    
Sorry, last comment didn't fully save. Is there a typo in the net use statement? I'd expect something like: NET USE H:\ \\server\share 1234abc /USER:cranew /PERSISTENT:yes –  Stuart Moore Oct 25 '12 at 6:53
add comment

2 Answers

This is more of a NET USE question than a SSMS/SQL Server question.

NET USE has the syntax:

net use [{DeviceName | *}] [\\ComputerName\ShareName[\volume]] [{Password | *}]] [/user:[DomainName]UserName] [/user:[DottedDomainName]UserName] [/user: [UserName@DottedDomainName] [/savecred] [/smartcard] [{/delete | /persistent:{yes | no}}]

So I expect your command to look like this:

EXEC xp_cmdshell 'NET USE H: \\568.256.8.358\backup_147 1234abc /USER:cranew /PERSISTENT:yes'
share|improve this answer
add comment

Don't map network drives and expect them to be there. Just backup to the network path directly.

Using mapped drives gets tricky fast as you start to make assumptions that the drive letter will be available next time. What happens when you add another hard drive to the server later and want to use that drive letter? What happens when Windows disconnects the drive to reclaim the network socket?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.