May 11, 2005 at 11:06 am
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
May 11, 2005 at 11:51 am
Instead of using the mapping, you can use UNC path like \\servername\sharename\..... in your xp commands.
May 12, 2005 at 11:40 am
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."
November 17, 2005 at 8:58 am
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