|
| 1 | + |
| 2 | +DECLARE @insertBrands INT = 0; |
| 3 | +DECLARE @insertTypes INT = 0; |
| 4 | +DECLARE @insertCatalog INT = 0; |
| 5 | + |
| 6 | +IF (OBJECT_ID('CatalogBrands') IS NOT NULL) |
| 7 | +BEGIN |
| 8 | + PRINT 'Table "CatalogBrands" exists' |
| 9 | +END |
| 10 | +ELSE BEGIN |
| 11 | + CREATE TABLE [CatalogBrands] ( |
| 12 | + Id INT NOT NULL PRIMARY KEY IDENTITY(1, 1), |
| 13 | + Brand NVARCHAR(100) NOT NULL, |
| 14 | + ); |
| 15 | + SET @insertBrands = 1; |
| 16 | +END; |
| 17 | + |
| 18 | +IF (OBJECT_ID('CatalogTypes') IS NOT NULL) |
| 19 | +BEGIN |
| 20 | + PRINT 'Table "CatalogTypes" exists' |
| 21 | +END |
| 22 | +ELSE BEGIN |
| 23 | + CREATE TABLE CatalogTypes ( |
| 24 | + Id INT NOT NULL PRIMARY KEY IDENTITY(1, 1), |
| 25 | + [Type] NVARCHAR(100) NOT NULL |
| 26 | + ); |
| 27 | + SET @insertTypes = 1; |
| 28 | +END; |
| 29 | + |
| 30 | +IF (OBJECT_ID('Catalog') IS NOT NULL) |
| 31 | +BEGIN |
| 32 | + PRINT 'Table "Catalog" exists'; |
| 33 | +END |
| 34 | +ELSE BEGIN |
| 35 | + CREATE TABLE [Catalog] ( |
| 36 | + Id INT PRIMARY KEY NOT NULL IDENTITY(1, 1), |
| 37 | + [Name] VARCHAR(50) NOT NULL, |
| 38 | + [Description] VARCHAR(MAX), |
| 39 | + Price DECIMAL(18, 2) NOT NULL, |
| 40 | + PictureUri VARCHAR(MAX) NOT NULL, |
| 41 | + CatalogTypeId INT NOT NULL, |
| 42 | + CatalogBrandId INT NOT NULL |
| 43 | + ); |
| 44 | + SET @insertCatalog = 1; |
| 45 | +END; |
| 46 | + |
| 47 | +IF @insertBrands = 1 |
| 48 | +BEGIN |
| 49 | + PRINT 'Inserting Brands' |
| 50 | + INSERT INTO [CatalogBrands]([Brand]) |
| 51 | + VALUES ('Azure'), |
| 52 | + ('.NET'), |
| 53 | + ('Visual Studio'), |
| 54 | + ('SQL Server'), |
| 55 | + ('Other') |
| 56 | +END; |
| 57 | + |
| 58 | +IF @insertTypes = 1 |
| 59 | +BEGIN |
| 60 | + PRINT 'Inserting types' |
| 61 | + INSERT INTO [CatalogTypes]([Type]) |
| 62 | + VALUES ('Mug'), |
| 63 | + ('T-Shirt'), |
| 64 | + ('Sheet'), |
| 65 | + ('USB Memory Stick') |
| 66 | +END; |
| 67 | + |
| 68 | +IF @insertCatalog = 1 |
| 69 | +BEGIN |
| 70 | + PRINT 'Inserting Types' |
| 71 | + INSERT INTO [Catalog]([Name], [Description], [Price], [PictureUri], [CatalogTypeId], [CatalogBrandId]) |
| 72 | + VALUEs ('.NET Bot Black Sweatshirt','.NET Bot Black Sweatshirt',19.50,'http://catalogbaseurltobereplaced/images/products/1.png',2,2), |
| 73 | + ('.NET Black & White Mug','.NET Black & White Mug',8.50,'http://catalogbaseurltobereplaced/images/products/2.png',1,2), |
| 74 | + ('Prism White T-Shirt','Prism White T-Shirt',12.00,'http://catalogbaseurltobereplaced/images/products/3.png',2,5), |
| 75 | + ('.NET Foundation Sweatshirt','.NET Foundation Sweatshirt',12.00,'http://catalogbaseurltobereplaced/images/products/4.png',2,2), |
| 76 | + ('Roslyn Red Sheet','Roslyn Red Sheet',8.50,'http://catalogbaseurltobereplaced/images/products/5.png',3,5), |
| 77 | + ('.NET Blue Sweatshirt','.NET Blue Sweatshirt',12.00,'http://catalogbaseurltobereplaced/images/products/6.png',2,2), |
| 78 | + ('Roslyn Red T-Shirt','Roslyn Red T-Shirt',12.00,'http://catalogbaseurltobereplaced/images/products/7.png',2,5), |
| 79 | + ('Kudu Purple Sweatshirt','Kudu Purple Sweatshirt',8.50,'http://catalogbaseurltobereplaced/images/products/8.png',2,5), |
| 80 | + ('Cup<T> White Mug','Cup<T> White Mug',12.00,'http://catalogbaseurltobereplaced/images/products/9.png',1,5), |
| 81 | + ('.NET Foundation Sheet','.NET Foundation Sheet',12.00,'http://catalogbaseurltobereplaced/images/products/10.png',3,2), |
| 82 | + ('Cup<T> Sheet','Cup<T> Sheet',8.50,'http://catalogbaseurltobereplaced/images/products/11.png',3,2), |
| 83 | + ('Prism White TShirt','Prism White TShirt',12.00,'http://catalogbaseurltobereplaced/images/products/12.png',2,5); |
| 84 | +END; |
0 commit comments