· 7 years ago · Oct 18, 2018, 05:32 PM
1SET ANSI_NULLS ON
2GO
3SET QUOTED_IDENTIFIER ON
4GO
5
6declare @localized_string_AddRole_Failed nvarchar(256)
7set @localized_string_AddRole_Failed = N'Failed adding the ''persistenceUsers'' role'
8
9DECLARE @ret int, @Error int
10IF NOT EXISTS( SELECT 1 FROM [dbo].[sysusers] WHERE name=N'persistenceUsers' and issqlrole=1 )
11 BEGIN
12
13 EXEC @ret = sp_addrole N'persistenceUsers'
14
15 SELECT @Error = @@ERROR
16
17 IF @ret <> 0 or @Error <> 0
18 RAISERROR( @localized_string_AddRole_Failed, 16, -1 )
19 END
20GO
21
22IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InstanceData]') AND type in (N'U'))
23 DROP TABLE [dbo].[InstanceData]
24GO
25CREATE TABLE [dbo].[InstanceData](
26 [id] [uniqueidentifier] NOT NULL,
27 [instance] [image] NULL,
28 [instanceXml] [xml] NULL,
29 [created] [datetime] NOT NULL,
30 [lastUpdated] [datetime] NOT NULL,
31 [lockOwner] [uniqueidentifier] NULL,
32 [lockExpiration] [datetime] NULL
33) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
34GO
35CREATE UNIQUE CLUSTERED INDEX id_index
36 ON [dbo].[InstanceData] ([id])
37 WITH IGNORE_DUP_KEY
38GO