Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2004, 03:22 AM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Backup With TSQL

Hi everyone
I have the folowing situations with my backups.
With Database Maintenance Plan is created backup strategy. Full Backup is performing every day at 1.00 am. And Romove files older than: is checked on 2 days, and it's working fine.

I am interested how can i perform this action with tsql, without using DMPlan.
I tryed this:
BACKUP DATABASE TEST TO DISK 'C:...' WITH INIT, RETAINDAYS = 2

I put this statement into job but it is not working. I tryed after that with (WITH NOINIT) but in that case .bak file grow and files older than 2 days are not deleted.

How can i delete files older then 2 days.
Thanks
 
Old April 29th, 2004, 08:40 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

There are two things you can do

Right click on the backup job and script it. Take a look at the parameters with Query Analyzer

Two.
Books oN line shows the format for backup
Backing up an entire database:

BACKUP DATABASE { database_name | @database_name_var }
TO < backup_device > [ ,...n ]
[ WITH
    [ BLOCKSIZE = { blocksize | @blocksize_variable } ]
    [ [ , ] DESCRIPTION = { 'text' | @text_variable } ]
    [ [ , ] DIFFERENTIAL ]
    [ [ , ] EXPIREDATE = { date | @date_var }
    | RETAINDAYS = { days | @days_var } ] [ [ , ] PASSWORD = { password | @password_variable } ]
    [ [ , ] FORMAT | NOFORMAT ]
    [ [ , ] { INIT | NOINIT } ]
    [ [ , ] MEDIADESCRIPTION = { 'text' | @text_variable } ]
    [ [ , ] MEDIANAME = { media_name | @media_name_variable } ]
    [ [ , ] MEDIAPASSWORD = { mediapassword | @mediapassword_variable } ]
    [ [ , ] NAME = { backup_set_name | @backup_set_name_var } ]
    [ [ , ] { NOSKIP | SKIP } ]
    [ [ , ] { NOREWIND | REWIND } ]
    [ [ , ] { NOUNLOAD | UNLOAD } ]
    [ [ , ] RESTART ]
    [ [ , ] STATS [ = percentage ] ]
]



 
Old April 29th, 2004, 11:01 PM
Authorized User
 
Join Date: Jun 2003
Posts: 77
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... and three: fire up SQL Profiler and peek at the command batches sent to the server by the database maintenance plan at 1:00 am.





Similar Threads
Thread Thread Starter Forum Replies Last Post
free ebooks on TSQL nazia SQL Server 2000 2 May 23rd, 2007 03:56 PM
Create backup folder & also backup files miracles Excel VBA 0 April 16th, 2007 02:28 AM
How to create table in Ms Access (TSQL) abdusalam SQL Server 2000 4 July 31st, 2004 01:54 AM
Chapter 4 TSQL error bboturla BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 3 July 2nd, 2004 10:16 AM
TSQL to get column values mstuart60 SQL Language 2 June 9th, 2003 04:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.