Attaching a file from Network Location

  • I have a backup on a server and I have a VM with SQL on it. Because my VM has limited space on it (99gb), my backup is 17gb expands to over 55gb.

    I have instances where I want to restore single rows from tables with a backup (from say, 2 days ago).

    I have a mapped drive S: where the backups are or I have a 192.168.xx.xx network address.

    I dont have enough room to copy 17gb to the VM and restore it, so can I attach the backup from a network location and get the data I want????

    Darryl Wilson
    darrylw99@hotmail.com

  • Yes.

    https://msdn.microsoft.com/en-us/library/hh759341.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • EXEC sp_configure 'show advanced options', 1;

    GO

    RECONFIGURE;

    GO

    EXEC sp_configure 'xp_cmdshell',1

    GO

    RECONFIGURE

    GO

    EXEC XP_CMDSHELL 'net use H: \\foldername1\foldername2\sharedfoldername3'

    EXEC XP_CMDSHELL 'Dir H:'

    EXEC XP_CMDSHELL 'net use H: /delete'

    EXEC sp_configure 'xp_cmdshell',0

    GO

    RECONFIGURE

    GO

  • sri2015 (12/23/2015)


    EXEC XP_CMDSHELL 'net use H: \\foldername1\foldername2\sharedfoldername3'

    EXEC XP_CMDSHELL 'Dir H:'

    EXEC XP_CMDSHELL 'net use H: /delete'

    Nope!

    SQL does not support mapped drives for database files, just the //server/share format, as per the article referenced above.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (12/23/2015)


    sri2015 (12/23/2015)


    EXEC XP_CMDSHELL 'net use H: \\foldername1\foldername2\sharedfoldername3'

    EXEC XP_CMDSHELL 'Dir H:'

    EXEC XP_CMDSHELL 'net use H: /delete'

    Nope!

    SQL does not support mapped drives for database files, just the //server/share format, as per the article referenced above.

    Actually, when created through SQL Server via xp_CmdShell, it does. Been doing it for years. It's just like any other user when you do it that way.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Ack, didn't notice that the 'not supported' list is for system database locations.

    But still, you don't need to go to the extra effort of mapping a drive that the SQL Server service account can see, the \\servername\share syntax for files works fine, without traceflag, from 2012 onwards

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 6 posts - 1 through 5 (of 5 total)

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