By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE #Food(
[Code] [nvarchar](50) NOT NULL,
[Group] [nvarchar](100) NULL,
[Quantity] [int] NOT NULL,
[Color] [nvarchar](50) NULL,
) ON [PRIMARY];
INSERT INTO #Food
( [Code], [Group], [Quantity],[Color] )
VALUES
('Apple', 'Fruit', 44, 'red'),
('Apple', 'Fruit', 1, 'yellow'),
('Pineapple', 'Fruit', 14, 'brown'),
('Apple', 'Fruit', 12, 'red'),
('Banana', 'Fruit', 1, 'yellow'),
('Tomatoes', 'Vegetables', 8, 'red'),
('Cucumbers', 'Vegetables', 3, 'green');
7 rows affected
SELECT *
FROM #Food
Code | Group | Quantity | Color |
---|---|---|---|
Apple | Fruit | 44 | red |
Apple | Fruit | 1 | yellow |
Pineapple | Fruit | 14 | brown |
Apple | Fruit | 12 | red |
Banana | Fruit | 1 | yellow |
Tomatoes | Vegetables | 8 | red |
Cucumbers | Vegetables | 3 | green |
ALTER TABLE #Food
ADD Price decimal(10,3) NOT NULL DEFAULT(0)
SELECT *
FROM #Food
Code | Group | Quantity | Color | Price |
---|---|---|---|---|
Apple | Fruit | 44 | red | 0.000 |
Apple | Fruit | 1 | yellow | 0.000 |
Pineapple | Fruit | 14 | brown | 0.000 |
Apple | Fruit | 12 | red | 0.000 |
Banana | Fruit | 1 | yellow | 0.000 |
Tomatoes | Vegetables | 8 | red | 0.000 |
Cucumbers | Vegetables | 3 | green | 0.000 |