I have a query below:
- select DATEDIFF(DAY, DateRequested, GETDATE()) as NumberOfDays from tblSeriesRequest
- UPDATE [dbo].[tblSeriesRequest] SET [IsCancelled] = 1
I tried the query below but it updates the whole rows.
- if exists(select 1 from tblSeriesRequest where (DATEDIFF(DAY, DateRequested, GETDATE())) > 30 and IsApproved <> 1)
- begin
- UPDATE [dbo].[tblSeriesRequest] SET [IsCancelled] = 1
- end
Can anyone show me how to do this? Many thanks in advance


Jignesh KumarRank #91 · 22.9K reputationPosted Aug 12, 2018, 7:41 PM EDT
Jes SieRank #1,285 · 1.3K reputationPosted Aug 12, 2018, 7:32 PM EDT
Jes SieRank #1,285 · 1.3K reputationPosted Aug 12, 2018, 9:27 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Aug 12, 2018, 10:04 PM EDT