December 1, 2010 at 3:29 pm
here is the script which works, backs up all databases. I need to backup one specific database only...
-----------------------------------------------START----------------------------
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
SET @path = 'C:\Backups\'
DECLARE db_cursor CURSOR FOR
SELECT name
FROM master.dbo.sysdatabases
WHERE name NOT IN ('tempdb')
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
SET @fileName = @path + @name + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName
WITH INIT
FETCH NEXT FROM db_cursor INTO @name
END
CLOSE db_cursor
DEALLOCATE db_cursor
--------------------------------------END--------------------------------
Can somone Help? Hope i posted this in the right area
December 1, 2010 at 4:11 pm
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
SET @path = 'C:\Backups\'
SET @name = 'Your DB Name HERE'
SET @fileName = @path + @name + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName
WITH INIT
December 2, 2010 at 12:55 am
The sql code within the cursor backups the db
The cursor is running for every db in the server
So concentrate in the cursor code, except fetch, etc codes replacing the cursor parameters with target database properties
There is an other sample at MS SQL Server Backup Script
December 2, 2010 at 6:48 am
Guys - Thank you very much! Works perfectly. Take Care
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply