SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Missing Dates in sql 2005 table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

6 Posts

Posted - 03/25/2012 :  10:23:40  Show Profile  Reply with Quote
My table looks like this

1,410100, 200,2012-01-01
2,410100, 250,2012-01-02
3,410100, 300,2012-01-04

I need to add (missing date 2012-01-03) and keep the same
date for previous record (2,410100,250,2012-01-02). This will apply for any missing date on the table.

Any help please!!!


Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 03/25/2012 :  12:05:22  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
You need a calendar table for this, a table that just contains sequential dates from a starting date to an ending date. Once you have that, it's a simple left join or not exists to find the dates that don't exists in your table.

Gail Shaw
SQL Server MVP
Go to Top of Page

Very Important crosS Applying yaK Herder

52325 Posts

Posted - 03/26/2012 :  13:13:21  Show Profile  Reply with Quote
see one here


SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000