0

I am trying to update a record in my MS SQL database but cannot seem to get the GETDATE() function to work.

Will somebody look at the code below and tell me were am going wrong?

BEGIN
    update Bookings
  set TotalBookings = TotalBookings+1
  set LastBooked = GETDATE()
  where PropertyId='1007' 
END
1

1 Answer 1

4

Your syntax is wrong it should be:

BEGIN
  update Bookings
  set TotalBookings = TotalBookings+1 ,
      LastBooked = GETDATE()
  where PropertyId='1007' 
END

You are using set multiple times, instead use set once and separate your columns with comma.

For more info see: UPDATE (Transact-SQL)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.