As with all things in SQL Server, it depends.
First thing you need to do is make sure you understand what each type of backup does.
Books Online has all the gooey details, but here's my summary.
A FULL backup contains everything within the database. A DIFFERENTIAL backup is cumlative NOT incremental. In your example, if your database failed on the 12th, then you'd only need to restore the full backup from the 1st and then the most recent differential on the 12th, then followed by all the transaction log backups upto the failure. A TRANSACTION LOG backup is only needed for databases using the full or bulk-logged recovery model. If you're using the simple recovery model then transaction log backups are not needed.
Now that we've cleared that up...Designing a backup schedule really depends on how much data you need to recovery and how fast you need to recover it in the event of a diaster. I would recommend starting with a full backup each day. You can always reduce the frequency later. Remember the differential backup is cumlative since the last full, so depending on the amount change going on in your database the differential could be larger than the full backup after a few days. If you do a full backup each day, then you may not need to use differentials at all; however you could still do it once a day and schedule it at 12 noon. The transaction log backup only backs up the log. The frequency of the log backup will determine how much data you're willing to lose in the event of a failure. If you run your log backup every 15 minutes, then you would expect to lose up to the last 15 minutes of data that changed. 15 minutes is a good frequency, but every 30 minutes works perfectly for my environment.
As I said earlier, it all depends on your environment. After you've designed and setup your backup schedule, remember to test it on an alternate server. Practice restoring your full, diff, and log backups so that you know everything works like you designed it.
Books Online has some good info if you plan use Maintenance Plans, but if you really want flexibility then check out Ola Hallengren's backup scripts.
Expanding on James' answer
Try this code on SqlFiddle.
Also check out @SqlKiwi Paul White's post regarding Delete vs Truncate
create table tracker_live (
client_nbr int not null, tracker_date date not null, submit_date date not null, live float not null, retainer float not null, bonus float not null
, constraint pk_tracker_live primary key (client_nbr, tracker_date, submit_date));
insert into tracker_live (client_nbr, tracker_date, submit_date, live, retainer, bonus) values
(9,'2014-10-01','2014-10-08',537841.5657,1,1)
,(9,'2014-11-01','2014-10-08',890293.714,2,2)
,(9,'2014-12-01','2014-10-08',45585.4029,3,3)
,(9,'2014-10-01','2014-10-17',537841.5657,1,1)
,(9,'2014-11-01','2014-10-17',890293.714,2,2)
,(9,'2014-12-01','2014-10-17',45585.4029,3,3)
,(9,'2014-10-01','2014-11-13',2321938.59,1,1)
,(9,'2014-11-01','2014-11-13',907925.1072,2,2)
,(9,'2014-12-01','2014-11-13',392917.5237,3,3)
,(9,'2014-10-01','2014-11-18',2321938.59,1,1)
,(9,'2014-11-01','2014-11-18',795725.1072,2,2)
,(9,'2014-12-01','2014-11-18',725835.0474,3,3)
create table tracker_live_last_month (
client_nbr int not null, tracker_date date not null, submit_date date not null, live float not null, retainer float not null, bonus float not null
, constraint pk_tracker_live_last_month primary key (client_nbr, tracker_date));
/* example query for procedure */
declare @test date;
set @test = '2014-11-18';
--set @test = convert(date,getdate());
declare @LastDayOfLastMonth date;
set @LastDayOfLastMonth = dateadd(day,-datepart(day,@test),@test);
declare @FirstDayOfLastMonth date;
set @FirstDayOfLastMonth = dateadd(day,1-datepart(day,@LastDayOfLastMonth),@LastDayOfLastMonth);
truncate table tracker_live_last_month;
/* inserting the data with this combined query should be quicker than creating the table and then updating values */
insert into tracker_live_last_month (client_nbr, tracker_date, submit_date, live, retainer, bonus)
select tl.client_nbr, tl.tracker_date, ca.submit_date, ca.live, ca.retainer, ca.bonus
from tracker_live tl
cross apply (select top 1 i.submit_date, i.live, i.retainer, i.bonus
from tracker_live i
where i.client_nbr=tl.client_nbr
and i.tracker_date=tl.tracker_date
order by i.submit_date desc) as ca
where tl.submit_date between @FirstDayOfLastMonth and @LastDayofLastMonth
group by tl.client_nbr, tl.tracker_date, ca.submit_date, ca.retainer, ca.live, ca.bonus
order by tl.client_nbr, tl.tracker_date, ca.submit_date, ca.retainer, ca.live, ca.bonus;
Best Answer