• J2B (8/26/2016)


    I need some help to remove the spaces from my backup job...

    Its outputting as:

    "dbname_DD MMM YYYY.bak"

    But I would like:

    "dbname_DDMMMYYYY.bak"

    Heres my T-SQL...

    USE dbname

    DECLARE @dbname varchar(200)

    SELECT @dbname='filepath\dbname_' + REPLACE(convert(varchar(20),GetDate(),106),':','-') + '.bak'

    BACKUP DATABASE [dbname] TO DISK=@dbname with compression

    Thanks

    Just as an "ease of maintenance" and "ease of discovery" for your backup file names, you should store the files with sortable names AND a time when the backup started in the form of dbName_YYYYMMDD_HHMISS. This is especially true when it comes to taking dozens of log file backups each day.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)