T-SQL Update table with results from Select Count
Posted on 2009-04-22
Trying to run a Count on a table to get the number of records the are in between 2 dates then update a record in another tabel in MS SQL2005 Express.
This code gives me an error as I am sure it is not right, but it does help to illustrate what I am trying to do.
UPDATE NRTOTALS SET nrvalue = ((SELECT COUNT(PROG_ID) FROM DPU817
WHERE (DATEDIFF(DAY, ANNIVDATE, GETDATE()) > 30) AND (DATEDIFF(DAY, ANNIVDATE, GETDATE()) < 60)
WHERE VALUENAME = 'nr3060')
Any help would be great.