• You are missing the increment of the counter, the code never hits it, improved code below

    😎

    --Set Variables for randomizing Information, et al

    DECLARE @localChestTier int, @ItemLimit int, @counter int,@ItemCounter int

    SET @counter = 1 -- outter chest counter

    SET @ItemCounter = 1 -- inner Items in each chest counter

    WHILE @counter <= 1000 -- create 1000 chests full of items

    BEGIN

    SET @localChestTier = 1; -- (SELECT Chests.ChestTier FROM Chests WHERE Chests.ChestID = @counter) -- Pulling item quality base line... TODO: this seems very rigid, examine better methods of implementation

    SET @ItemLimit = 10 --(ABS(CHECKSUM(NEWID())) % (@localChestTier * 2)) + 1 -- double base tier for item cap

    BEGIN

    WHILE @ItemCounter <= @ItemLimit

    BEGIN

    INSERT INTO ChestItems --Join Table

    SELECT

    --ChestItemsID Primary Key Auto incremented

    @counter,--ChestID from Chests

    (SELECT TOP 1 Items.ItemID FROM Items WHERE Items.ItemTier = @localChestTier)--ItemID from Items

    SET @ItemCounter +=1 -- next item

    END

    SET @counter += 1 -- next chest

    END

    END