Disconnected network drive still available in SQL Server

  • Hello,

     

    Can Anyone please help me with the following problem:

    I wrote a stored procedure in SQL Server 2000 to check if a certain drive mapping is still available on the server. If not, the proc restores this mapping. I use both master..xp_fileexist and master..xp_cmdshell 'net use' to check if it exists.

    Everything seems to work fine, until I use remote desktop to connect to the server and disconnect the drive mapping manually. Now the drive mapping is gone in windows explorer. I then run the proc again and it says the drive mapping still exists... Also, exec mast..xp_cmdshell 'dir g:' gives me the contents of the directory. So this seems to be a SQL Server caching problem. Anyone have a solution?

    Greetz,

     

    Bart

  • Instead of using the mapping, you can use UNC path like \\servername\sharename\..... in your xp commands.

  • 3 things. First to make the mapping 'go away' in SQL Server you will have to stop and restart SQL Server. Second, if you use this again, I'd also add /PERSISTENT:NO. Finally when doing a NET USE to check for existance and it's successful do not forget to perform a NET USE /DELETE as well. The NET USE and corresponding DELETE need to originate from the same spid as well.

     

    The reason that the connections do not drop is because they are 'owned' by SQL Server (if done via QA) or the SQL Agent (if done via scheduled task)

     

    UNC naming is the way to go, however I've resorted to this in environments that were either clasified as having 'draconian' security or 'flaky' networks. Good Luck !!

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • Thanks guys. I'm a bit late, but the priority of this issue suddenly dropped. I now have more time, so I'll try your solutions.

    Best regards,

     

    Bart Blesgraaf

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply