Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need TSQL Cursor Help!

Author  Topic 

gtops1
Starting Member

2 Posts

Posted - 2009-07-30 : 09:09:53
Hi There..Im trying to use a cursor to find missing weekly entries from a table, the problem is im new to sql and dont know if this is even possible?

My table looks something like this;

| Account | Date | Bal |
| 17345 | 05/01/09 | 100 |
| 12376 | 05/08/09 | 135 |
| 12547 | 05/22/09 | 123 |
| 12331 | 05/29/09 | 112 |
| 12341 | 06/05/09 | 118 |
| 13475 | 06/19/09 | 114 |


In this case the missing weekly entries are 05/15/09 and 06/19/09, so idealy if i could have a cursor that would automatically go through the table, find missing date entries and display these missing dates in a different table it would be awesome..if anyone has any idea on how this could be done it would be very much appreciated!

DavidChel
Constraint Violating Yak Guru

474 Posts

Posted - 2009-07-30 : 09:24:47
Wouldn't the second missing date be 6/12?
Go to Top of Page

gtops1
Starting Member

2 Posts

Posted - 2009-07-30 : 11:44:45
Ha yeaaah, okay my Math skills and SQL skills arent the best..
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-30 : 11:47:26
If you do not already have a Date table you could create one and LEFT join from that to your table to get the missing week dates.
Go to Top of Page
   

- Advertisement -