Update table with random DECIMAL number within a range (SQL Server)

Viewed 11278

I want to update the column ItemValue of table Items with a decimal value generated randomly within 1 and 100 (a different value for each row). Each value should have two (random) digits.

CREATE TABLE Items
(
    ItemID int IDENTITY(1,1) NOT NULL,
    ItemValue decimal(13, 4) NULL,
    CONSTRAINT PK_Items PRIMARY KEY CLUSTERED (ItemID ASC)
)

INSERT INTO Items(ItemValue) VALUES (0)
INSERT INTO Items(ItemValue) VALUES (0)
INSERT INTO Items(ItemValue) VALUES (0)
INSERT INTO Items(ItemValue) VALUES (0)

-- Now, I want to update the table
2 Answers
Related