Refresh a column every 2 hours

Asked

Viewed 39 times

0

I have a column with values more accurate that every 2 hours it increases +1. for the player to buy as soon as possible.

CREATE TABLE [dbo].[Produtos_Offer](
    [x_Item] [int] NOT NULL,
    [Preço] [int] NOT NULL,
    [Valor] [int] NOT NULL
)

UPDATE Produtos_Offer SET Valor = Valor +1 WHERE x_Item = 0267

  • creates a job and schedule to run every 2 hours

  • Note that the way you did your SET you are assigning 1 to the Value field and not adding 1, see the correct form in Rodrigo Nascentes' answer. As for the periodic execution follow Ricardo Pontual’s tip.

1 answer

0

For addition assignment in SQL Server you can use the operator +=

UPDATE Produtos_Offer SET Valor += 1 WHERE x_Item = 0267

It has the same effect as:

UPDATE Produtos_Offer SET Valor = Valor + 1 WHERE x_Item = 0267
  • Yes, thank you. Corrected!

  • @Jor - Could you please mark the answer as useful? Brawl.

  • Level-less

Browser other questions tagged

You are not signed in. Login or sign up in order to post.