-1
UPDATE TimeRecord 
SET activityid = 151
WHERE timevalue >= '13:00:00.0'

When I run the query it updates every record instead of the ones greater than the specified timevalue

The timevalue column is formatted as follows

2012-05-24 13:00:00.0
Adam Wenger
  • 17,100
  • 6
  • 52
  • 63
bird2920
  • 373
  • 2
  • 9

1 Answers1

1

Without a date specified, you default to January, 01 1900 13:00:00, so you're asking to update any value where timevalue is after that date, which is quite likely all of them.

You probably want to use:

UPDATE TimeRecord 
SET activityid = 151
WHERE DATEPART(HOUR, timevalue) > 13;
Adam Wenger
  • 17,100
  • 6
  • 52
  • 63