/************************************************************/
/*****              SqlDataProvider                     *****/
/*****                                                  *****/
/*****                                                  *****/
/***** Note: To manually execute this script you must   *****/
/*****       perform a search and replace operation     *****/
/*****       for {databaseOwner} and {objectQualifier}  *****/
/*****                                                  *****/
/************************************************************/
 
 
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}{objectQualifier}DynamicForms_FormData') AND type in (N'U'))
BEGIN
CREATE TABLE {databaseOwner}{objectQualifier}DynamicForms_FormData(
    [RecordID] [int] NOT NULL,
    [FormID] [int] NOT NULL,
    [FieldID] [nvarchar](50) NOT NULL,
    [FieldType] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_DynamicForms_FormData] PRIMARY KEY CLUSTERED 
(
    [RecordID] ASC,
    [FormID] ASC,
    [FieldID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
 
 
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}{objectQualifier}DynamicForms_RecordData') AND type in (N'U'))
BEGIN
CREATE TABLE {databaseOwner}{objectQualifier}DynamicForms_RecordData(
    [RecordID] [int] NOT NULL,
    [FieldID] [nvarchar](50) NOT NULL,
    [FieldValue] [nvarchar](500) NULL,
 CONSTRAINT [PK_DynamicForms_RecordData] PRIMARY KEY CLUSTERED 
(
    [RecordID] ASC,
    [FieldID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
 
 
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}{objectQualifier}DynamicForms_RecordData_Large') AND type in (N'U'))
BEGIN
CREATE TABLE {databaseOwner}{objectQualifier}DynamicForms_RecordData_Large(
    [RecordID] [int] NOT NULL,
    [FieldID] [nvarchar](50) NOT NULL,
    [FieldValue] [text] NULL,
 CONSTRAINT [PK_DynamicForms_RecordData_Large] PRIMARY KEY CLUSTERED 
(
    [RecordID] ASC,
    [FieldID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
 
 
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}{objectQualifier}DynamicForms_Forms') AND type in (N'U'))
BEGIN
CREATE TABLE {databaseOwner}{objectQualifier}DynamicForms_Forms(
    [FormID] [int] IDENTITY(1,1) NOT NULL,
    [FormName] [nvarchar](100) NOT NULL,
    [ControlName] [nvarchar](200) NOT NULL,
 CONSTRAINT [PK_DynamicForms_Forms] PRIMARY KEY CLUSTERED 
(
    [FormID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
 
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}{objectQualifier}DynamicForms_Records') AND type in (N'U'))
BEGIN
CREATE TABLE {databaseOwner}{objectQualifier}DynamicForms_Records(
    [RecordID] [int] IDENTITY(1,1) NOT NULL,
    [PortalID] [int] NOT NULL,
    [RecordName] [nvarchar](200) NOT NULL,
 CONSTRAINT [PK_DynamicForms_Records_1] PRIMARY KEY CLUSTERED 
(
    [RecordID] ASC,
    [PortalID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
 
GO
 
INSERT INTO {databaseOwner}{objectQualifier}DynamicForms_Forms 
(FormName, ControlName) 
 VALUES ('Process 1','Control1')
Go
INSERT INTO {databaseOwner}{objectQualifier}DynamicForms_Forms 
(FormName, ControlName) 
 VALUES ('Process 2','Control2')
 
 
/************************************************************/
/*****              SqlDataProvider                     *****/
/************************************************************/