Link to home
Start Free TrialLog in
Avatar of KenshiroM
KenshiroM

asked on

How do i change the Backup Folder Destination (SQL Server 2005)

Hi Guys,

I am doing an automatic backup of my databases, and they are being saved on C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup. Since i dont have enough space on the C drive, i want that they automatically go to a specified destination on another Hard Drive.

This is the code im using:

<--- Start--->

declare @cmd nvarchar(2000)
declare bcur cursor for

SELECT N'BACKUP DATABASE ' + name + ' TO DISK = '''+name+'-Data''
WITH NAME = N'''+name+'-Full Database Backup'', DESCRIPTION = N''Full Production Instance'', MEDIANAME = N'''+name+'Media'', MEDIADESCRIPTION = N'''+name+' Backup Media Set'', FORMAT, INIT'
FROM master..sysdatabases
WHERE name NOT LIKE 'TempDB'

open bcur

fetch next from bcur into @cmd

WHILE @@FETCH_STATUS = 0
begin
   exec sp_executesql @cmd
   fetch next from bcur into @cmd
end

close bcur
deallocate bcur

<--- End of Code--->
ASKER CERTIFIED SOLUTION
Avatar of imran_fast
imran_fast

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of imran_fast
imran_fast

or you can change default sql backup location from the reqistry

Here's a registry key you can modify, however:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\BackupDirectory