I have a small SQL database which i use to update a screen in our telesales office with numbers of queued calls and missed called.the table (named phone) is made up of three columns, missed, queue and date.the table is updated by our voicemail system via an update query, this works fine. However i have to reset the values to zero each morning.i want to change the update query so that is reads the date from the date column compares it to todays date and then clears both of the columns and starts again.here is what i have,declare @todaydate DATETIME SELECT DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0) as todaydate declare @testdate DATETIME select date from phoneif @testdate <> @todaydateBEGINupdate phone set date = DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0)update phone set missed = 1ENDelse BEGINupdate phone set missed = missed+1END
as far as i can see this should work, it will output the dates correctly but doesnt seem to compare them.also will this query work with SQL 2008, we are getting a new server next month and it will have 2008 on.Any help will be appreciated.Regards