Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I would like to run an update on a user table but dependant on the date that they last used. So the query would be:UPDATE USERS SET GROUPID = '9' WHERE LASTACCESSDATE = ?How can I set a time period of lastaccessdate is older than 12 months that I can run at any point in time without having to change? Also I would like to exclude any dates that are null?
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-10-07 : 11:44:25
Did you meant this?
UPDATE USERS SET GROUPID = '9' WHERE LASTACCESSDATE <=DATEADD(mm,DATEDIFF(mm,0,GETDATE())-12,0)