0
Good afternoon! I am with a situation in my service, I am beginner in sql server and would like a help or tip if possible. I have some records (54) of a table that need to be changed its code ordering from 1 to 54. I tried using to declare a float variable, but when running in the database all the records of the table in the column "CODIGOVENDA
" were changed to numbering "1". I am using the query below:
DECLARE @CONTADOR FLOAT
DECLARE @MAXIMO FLOAT
SET @CONTADOR = 0 SET @MAXIMO = 54
WHILE @CONTADOR < @MAXIMO
UPDATE VENDAS SET CODIGOVENDA = @CONTADOR + 1
Could someone give me a strength on how to perform this procedure correctly, please
Do you have any columns to sort? A sale date or something?
– Sorack
Very strange the way you are doing, it is not the usual way to work with SQL, but, I believe, somewhere in your process you have to increment the variable @COUNTER. The way it is, everything points to an infinite loop.
– anonimo