• I do backups frequently from my computer which is different from the server on which the database resides. But I want the backup to end up on my computer. This requires making use of a special kind of net share. The BAT file below shows what I mean.

    set backupdir=C:\Backup

    set database=MYDATABASE

    set sqlserver=SQLSERVER

    set sqluser=SQLUSER

    set sqlpassword=SQLPASSWORD

    echo backup database %database% to disk='\\%computername%\backup\%database%.bak' with stats=1 > backup.sql

    erase %backupdir%\%database%.bak

    net share backup /d

    net share backup=%backupdir%

    sqlcmd -S %sqlserver% -U %sqluser% -P %sqlpassword% -d %database% -i backup.sql

    net share backup /d

    erase backup.sql

    On occasion, I have to use my computer's IP address. A non-server's IP address can change (for various reasons) and getting the IP addess is just a little tricky - but not impossible.