IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[QX_HEADER]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[QX_HEADER]
GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[QX_ROW]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[QX_ROW]
GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[QX_COL]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[QX_COL]
GO

create table dbo.QX_HEADER (
  FORM_ID              VARCHAR(255) NOT NULL,
  HEADER_ORDER         INT NOT NULL,
  CLIENT_WIDTH         INT,
constraint PK_QX_HEADER primary key (FORM_ID, HEADER_ORDER)
)
GO

create table dbo.QX_ROW (
  FORM_ID              VARCHAR(255) NOT NULL,
  ROW_ORDER            INT NOT NULL,
constraint PK_QX_ROW primary key (FORM_ID, ROW_ORDER)
)
GO

create table dbo.QX_COL (
  ROW_ORDER            VARCHAR(255) NOT NULL,
  FORM_ID              VARCHAR(255) NOT NULL,
  COL_ORDER            INT NOT NULL,
  FIELD_ID             VARCHAR(255),
  ROWSPAN              INT,
  COLSPAN              INT,
constraint PK_QX_COL primary key (ROW_ORDER, FORM_ID, COL_ORDER)
)  
GO

UPDATE QX_SYS_PROP SET PROP_VAL = '008' WHERE (PROP_ID = 'DB_CORE_VERSION');
