· 7 years ago · Sep 17, 2018, 06:06 AM
1/*
2Deployment script for Keem_scorefeederweb
3
4This code was generated by a tool.
5Changes to this file may cause incorrect behavior and will be lost if
6the code is regenerated.
7*/
8
9GO
10SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;
11
12SET NUMERIC_ROUNDABORT OFF;
13
14
15GO
16:setvar DatabaseName "Keem_scorefeederweb"
17:setvar DefaultFilePrefix "Keem_scorefeederweb"
18:setvar DefaultDataPath "C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\"
19:setvar DefaultLogPath "C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\"
20
21GO
22:on error exit
23GO
24/*
25Detect SQLCMD mode and disable script execution if SQLCMD mode is not supported.
26To re-enable the script after enabling SQLCMD mode, execute the following:
27SET NOEXEC OFF;
28*/
29:setvar __IsSqlCmdEnabled "True"
30GO
31IF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
32 BEGIN
33 PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
34 SET NOEXEC ON;
35 END
36
37
38GO
39USE [$(DatabaseName)];
40
41
42GO
43PRINT N'Dropping <unnamed>...';
44
45
46GO
47EXECUTE sp_droprolemember @rolename = N'db_owner', @membername = N'Keem_admin';
48
49
50GO
51PRINT N'Starting rebuilding table [dbo].[Matches]...';
52
53
54GO
55BEGIN TRANSACTION;
56
57SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
58
59SET XACT_ABORT ON;
60
61CREATE TABLE [dbo].[tmp_ms_xx_Matches] (
62 [Id] INT IDENTITY (1, 1) NOT NULL,
63 [Date] NVARCHAR (100) NULL,
64 [TeamOneId] INT NOT NULL,
65 [TeamTwoId] INT NOT NULL,
66 [TeamOneScore] INT NOT NULL,
67 [TeamTwoScore] INT NOT NULL,
68 [SportId] INT DEFAULT ((0)) NOT NULL,
69 CONSTRAINT [tmp_ms_xx_constraint_PK_dbo.Matches1] PRIMARY KEY CLUSTERED ([Id] ASC)
70);
71
72IF EXISTS (SELECT TOP 1 1
73 FROM [dbo].[Matches])
74 BEGIN
75 SET IDENTITY_INSERT [dbo].[tmp_ms_xx_Matches] ON;
76 INSERT INTO [dbo].[tmp_ms_xx_Matches] ([Id], [Date], [TeamOneId], [TeamTwoId], [TeamOneScore], [TeamTwoScore])
77 SELECT [Id],
78 [Date],
79 [TeamOneId],
80 [TeamTwoId],
81 [TeamOneScore],
82 [TeamTwoScore]
83 FROM [dbo].[Matches]
84 ORDER BY [Id] ASC;
85 SET IDENTITY_INSERT [dbo].[tmp_ms_xx_Matches] OFF;
86 END
87
88DROP TABLE [dbo].[Matches];
89
90EXECUTE sp_rename N'[dbo].[tmp_ms_xx_Matches]', N'Matches';
91
92EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_dbo.Matches1]', N'PK_dbo.Matches', N'OBJECT';
93
94COMMIT TRANSACTION;
95
96SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
97
98
99GO
100PRINT N'Altering [dbo].[Teams]...';
101
102
103GO
104ALTER TABLE [dbo].[Teams]
105 ADD [SportId] INT DEFAULT ((0)) NOT NULL;
106
107
108GO
109PRINT N'Creating [dbo].[Sports]...';
110
111
112GO
113CREATE TABLE [dbo].[Sports] (
114 [Id] INT IDENTITY (1, 1) NOT NULL,
115 [Name] NVARCHAR (MAX) NULL,
116 CONSTRAINT [PK_dbo.Sports] PRIMARY KEY CLUSTERED ([Id] ASC)
117);
118
119
120GO
121PRINT N'Update complete.';
122
123
124GO