SQL Server Performance

Backup MASTER,MODEL,MSDB

Discussion in 'Contribute Your SQL Server Scripts' started by ghemant, Sep 24, 2005.

  1. ghemant Moderator

    declare @int int ,@dbname varchar(22)
    set @int = 0
    while (@int < 5)
    begin
    set @dbname = (select [name] from sysdatabases where dbid=@int)
    if (@dbname != 'tempdb')
    begin
    BACKUP DATABASE @dbname
    to DISK = @dbname
    WITH INIT
    end
    set @int = @int + 1
    continue
    break
    end

    Hemantgiri S. Goswami
    ghemant@gmail.com
    "Humans don't have Caliber to PASS TIME , Time it self Pass or Fail Humans" - by Hemantgiri Goswami
  2. Madhivanan Moderator

    sysdatabases should be Master..sysdatabases [<img src='/community/emoticons/emotion-1.gif' alt=':)' />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
  3. Madhivanan Moderator

    Other Way

    Run this

    Select 'Backup Database '+name +' To disk = C:'+Name+'.Bak WITH INIT' from Master..SysDatabases where DBId in (1,3,4)

    Copy the results back to Query Analyser and run them




    Madhivanan

    Failing to plan is Planning to fail

Share This Page