---Script to take all the database full backups of SQL Server
DECLARE @database varchar(4000)
DECLARE database_cursor CURSOR FOR
select name from master..sysdatabases
where name Not IN
(
'Tempdb'
)
OPEN database_cursor
FETCH NEXT FROM database_cursor INTO @database
while @@FETCH_STATUS = 0
BEGIN
BEGIN
DECLARE @filepath_name varchar (4000)
DECLARE @date varchar (2)
set @filepath_name = 'C:\SQLServer\Backup_Project\'+@database+'.bak'
BACKUP DATABASE @database
TO DISK = @filepath_name
WITH CHECKSUM, INIT , STATS = 5, DESCRIPTION = N'Complete Backup'
END
FETCH NEXT FROM database_cursor INTO @database
END
CLOSE database_cursor
DEALLOCATE database_cursor
DECLARE @database varchar(4000)
DECLARE database_cursor CURSOR FOR
select name from master..sysdatabases
where name Not IN
(
'Tempdb'
)
OPEN database_cursor
FETCH NEXT FROM database_cursor INTO @database
while @@FETCH_STATUS = 0
BEGIN
BEGIN
DECLARE @filepath_name varchar (4000)
DECLARE @date varchar (2)
set @filepath_name = 'C:\SQLServer\Backup_Project\'+@database+'.bak'
BACKUP DATABASE @database
TO DISK = @filepath_name
WITH CHECKSUM, INIT , STATS = 5, DESCRIPTION = N'Complete Backup'
END
FETCH NEXT FROM database_cursor INTO @database
END
CLOSE database_cursor
DEALLOCATE database_cursor
No comments:
Post a Comment