USE [FAMILY_DATA]
GO
/****** Object:  UserDefinedDataType [dbo].[TFID]    Script Date: 10/04/2019 10:55:59 ******/
CREATE TYPE [dbo].[TFID] FROM [char](12) NOT NULL
GO
/****** Object:  UserDefinedDataType [dbo].[TPID]    Script Date: 10/04/2019 10:55:59 ******/
CREATE TYPE [dbo].[TPID] FROM [char](11) NOT NULL
GO
/****** Object:  UserDefinedDataType [dbo].[TZIP_CODE]    Script Date: 10/04/2019 10:55:59 ******/
CREATE TYPE [dbo].[TZIP_CODE] FROM [char](4) NOT NULL
GO
/****** Object:  UserDefinedTableType [dbo].[PIDS]    Script Date: 10/04/2019 10:55:59 ******/
CREATE TYPE [dbo].[PIDS] AS TABLE(
	[PID] [nvarchar](11) NULL
)
GO
/****** Object:  UserDefinedFunction [dbo].[FN_GET_PERSON_AGE]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[FN_GET_PERSON_AGE](
	 @BIRTH_DATE DATETIME
	,@DT Datetime)
RETURNS int
AS
BEGIN
  DECLARE
    @person_age int
  SELECT @person_age = FLOOR((CAST (@DT AS INTEGER) - CAST(@BIRTH_DATE AS INTEGER)) / 365.25)
  RETURN (@person_age)
END
GO
/****** Object:  UserDefinedFunction [dbo].[fn_con2utf8]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[fn_con2utf8](@ascii nvarchar(1000))
RETURNS nvarchar(1000)
AS
BEGIN
  DECLARE 
    @result nvarchar(1000)
  SET @result = N''
  DECLARE
    @ascii_char nchar(1),
    @utf_char nchar(1)
  DECLARE
    @I int
  SET @I=1
  WHILE @I <= LEN(@ascii)
  BEGIN
    SET @ascii_char=SUBSTRING(@ascii,@I,1)
    SET @utf_char= 
    CASE @ascii_char
      WHEN N'À' THEN N'ა' WHEN N'Á' THEN N'ბ' WHEN N'Â' THEN N'გ' WHEN N'Ã' THEN N'დ'
      WHEN N'Ä' THEN N'ე' WHEN N'Å' THEN N'ვ' WHEN N'Æ' THEN N'ზ' WHEN N'È' THEN N'თ'
      WHEN N'É' THEN N'ი' WHEN N'Ê' THEN N'კ' WHEN N'Ë' THEN N'ლ' WHEN N'Ì' THEN N'მ'
      WHEN N'Í' THEN N'ნ' WHEN N'Ï' THEN N'ო' WHEN N'Ð' THEN N'პ' WHEN N'Ñ' THEN N'ჟ'
      WHEN N'Ò' THEN N'რ' WHEN N'Ó' THEN N'ს' WHEN N'Ô' THEN N'ტ' WHEN N'Ö' THEN N'უ'
      WHEN N'×' THEN N'ფ' WHEN N'Ø' THEN N'ქ' WHEN N'Ù' THEN N'ღ' WHEN N'Ú' THEN N'ყ'
      WHEN N'Û' THEN N'შ' WHEN N'Ü' THEN N'ჩ' WHEN N'Ý' THEN N'ც' WHEN N'Þ' THEN N'ძ'
      WHEN N'ß' THEN N'წ' WHEN N'à' THEN N'ჭ' WHEN N'á' THEN N'ხ' WHEN N'ã' THEN N'ჯ'   WHEN N'ä' THEN N'ჰ'
    ELSE @ascii_char
    END
    SET @result = @result + @utf_char
    SET @I=@I+1
  END
    

  RETURN @result
END

GO
/****** Object:  UserDefinedFunction [dbo].[fn_conutf82alta]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[fn_conutf82alta](@ascii nvarchar(1000))
RETURNS varchar(1000)
AS
BEGIN
  DECLARE 
    @result nvarchar(1000)
  SET @result = N''
  DECLARE
    @ascii_char char(1),
    @utf_char nchar(1)
  DECLARE
    @I int
  SET @I=1
  WHILE @I <= LEN(@ascii)
  BEGIN
    SET @utf_char=convert(nchar(1), SUBSTRING(@ascii,@I,1)) 
    SET @ascii_char= 
    CASE @utf_char
      WHEN N'ა' THEN 'À' WHEN N'ბ' THEN 'Á' WHEN N'გ' THEN 'Â' WHEN N'დ' THEN 'Ã'
      WHEN N'ე' THEN 'Ä' WHEN N'ვ' THEN 'Å' WHEN N'ზ' THEN 'Æ' WHEN N'თ' THEN 'È'
      WHEN N'ი' THEN 'É' WHEN N'კ' THEN 'Ê' WHEN N'ლ' THEN 'Ë' WHEN N'მ' THEN 'Ì'
      WHEN N'ნ' THEN 'Í' WHEN N'ო' THEN 'Ï' WHEN N'პ' THEN 'Ð' WHEN N'ჟ' THEN 'Ñ'
      WHEN N'რ' THEN 'Ò' WHEN N'ს' THEN 'Ó' WHEN N'ტ' THEN 'Ô' WHEN N'უ' THEN 'Ö'
      WHEN N'ფ' THEN '×' WHEN N'ქ' THEN 'Ø' WHEN N'ღ' THEN 'Ù' WHEN N'ყ' THEN 'Ú'
      WHEN N'შ' THEN 'Û' WHEN N'ჩ' THEN 'Ü' WHEN N'ც' THEN 'Ý' WHEN N'ძ' THEN 'Þ'
      WHEN N'წ' THEN 'ß' WHEN N'ჭ' THEN 'à' WHEN N'ხ' THEN 'á' WHEN N'ჯ' THEN 'ã'   
      WHEN N'ჰ' THEN 'ä'
    ELSE CHAR(ASCII(@utf_char))
    END
    SET @result = @result + @ascii_char
    SET @I=@I+1
  END
    

  RETURN @result
END
GO
/****** Object:  UserDefinedFunction [dbo].[fn_get_family_persons]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[fn_get_family_persons](@fid TFID)
RETURNS nvarchar(1000)
AS
BEGIN
  DECLARE
    @family_persons nvarchar(1000)

  SET @family_persons = ''

  SELECT @family_persons = @family_persons + CASE WHEN ITEM_NO = 1 THEN '' ELSE '; ' END + LAST_NAME + ' ' + FIRST_NAME
  FROM dbo.FAMILY_DATA_PERSONS (NOLOCK)
  WHERE FID=@fid
  ORDER BY ITEM_NO
 
  
  RETURN (@family_persons)
END
GO
/****** Object:  UserDefinedFunction [dbo].[fn_get_real_family_persons]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[fn_get_real_family_persons](@fid TFID)
RETURNS nvarchar(1000)
AS
BEGIN
  DECLARE
    @family_persons nvarchar(1000)

  SET @family_persons = ''

  SELECT @family_persons = @family_persons + CASE WHEN ITEM_NO = 1 THEN '' ELSE '; ' END + LAST_NAME + ' ' + FIRST_NAME
  FROM dbo.FAMILY_DATA_PERSONS (NOLOCK)
  WHERE FID=@fid and ([ACTION_TYPE] is null or [ACTION_TYPE] = 100)
  ORDER BY ITEM_NO
 
  
  RETURN (@family_persons)
END
GO
/****** Object:  Table [dbo].[DECLARATIONS_V1V2_ARC]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DECLARATIONS_V1V2_ARC](
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ROW_VERSION] [int] NULL,
	[REC_STATE] [tinyint] NOT NULL,
	[REC_DATE] [smalldatetime] NOT NULL,
	[PARENT_REC_ID] [int] NOT NULL,
	[REC_VERSION] [tinyint] NOT NULL,
	[TRUE_VER_REC_ID] [int] NULL,
	[WITH_ERROR] [bit] NOT NULL,
	[OWNER] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[SACODE] [int] NOT NULL,
	[FID] [dbo].[TFID] NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NULL,
	[CITY] [nvarchar](50) NULL,
	[REGION] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[ADDRESS] [nvarchar](50) NULL,
	[ADDRESS_NO] [nvarchar](50) NULL,
	[HOME_1] [nvarchar](50) NULL,
	[HOME_2] [nvarchar](50) NULL,
	[HOME_PHONE] [nvarchar](50) NULL,
	[HOME_PHONE_ALT] [nvarchar](50) NULL,
	[HOME_PHONE_ALT_DESCRIP] [nvarchar](50) NULL,
	[MOB_PHONE_1] [nvarchar](50) NULL,
	[MOB_PHONE_2] [nvarchar](50) NULL,
	[FO_FIRST_NAME] [nvarchar](50) NOT NULL,
	[FO_LAST_NAME] [nvarchar](50) NOT NULL,
	[FO_PID] [char](11) NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[ORDER_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[DECLARATION_FAMILY_QUEST_ARC_TRANSFORMATION]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DECLARATION_FAMILY_QUEST_ARC_TRANSFORMATION](
	[QTYPE_V1] [varchar](4) NOT NULL,
	[QID_V1] [int] NOT NULL,
	[QTYPE_V2] [varchar](4) NOT NULL,
	[QID_V2] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[DECLARATION_FAMILY_QUEST_V1V2_ARC]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DECLARATION_FAMILY_QUEST_V1V2_ARC](
	[FID] [dbo].[TFID] NOT NULL,
	[DID] [int] NOT NULL,
	[ITEM_NO] [tinyint] NOT NULL,
	[QTYPE] [char](4) NOT NULL,
	[QID] [tinyint] NOT NULL,
	[QVALUE_TYPE] [varchar](50) NULL,
	[QVALUE_BIT] [bit] NULL,
	[QVALUE_INT] [int] NULL,
	[QVALUE_MONEY] [money] NULL,
	[QVALUE_TEXT] [varchar](255) NULL,
 CONSTRAINT [PK_DECLARATION_FAMILY_QUEST_V2_ARC] PRIMARY KEY CLUSTERED 
(
	[FID] ASC,
	[DID] ASC,
	[ITEM_NO] ASC,
	[QTYPE] ASC,
	[QID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[DECLARATION_FAMILY_V1V2_ARC]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DECLARATION_FAMILY_V1V2_ARC](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[DID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[SEX] [smallint] NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[AGE] [int] NOT NULL,
	[PID] [nvarchar](50) NOT NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[ACTION_TYPE] [int] NULL,
	[PERSON_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[DECLARATION_QUEST_ARC_TRANSFORMATION]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DECLARATION_QUEST_ARC_TRANSFORMATION](
	[QTYPE_V1] [varchar](4) NOT NULL,
	[QID_V1] [int] NOT NULL,
	[QTYPE_V2] [varchar](4) NOT NULL,
	[QID_V2] [int] NOT NULL,
	[QTYPE_V2_TRANS] [varchar](4) NOT NULL,
	[QID_V2_TRANS] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[DECLARATION_QUEST_V1V2_ARC]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DECLARATION_QUEST_V1V2_ARC](
	[FID] [dbo].[TFID] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[QTYPE] [char](4) NOT NULL,
	[QID] [tinyint] NOT NULL,
	[QVALUE_TYPE] [varchar](10) NOT NULL,
	[QVALUE_BIT] [bit] NULL,
	[QVALUE_INT] [int] NULL,
	[QVALUE_MONEY] [money] NULL,
	[QVALUE_TEXT] [varchar](255) NULL,
 CONSTRAINT [PK_DECLARATION_QUEST_V2_ARC_1] PRIMARY KEY CLUSTERED 
(
	[FID] ASC,
	[REC_ID] ASC,
	[QTYPE] ASC,
	[QID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[FAMILY_DATA]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FAMILY_DATA](
	[FID] [dbo].[TFID] NOT NULL,
	[STATE] [tinyint] NOT NULL,
	[CALC_DATE] [smalldatetime] NULL,
	[ADT] [smalldatetime] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[SACODE] [int] NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [varchar](50) NULL,
	[REGION] [varchar](50) NULL,
	[GOVERNMENT] [varchar](50) NULL,
	[VILLAGE] [varchar](50) NULL,
	[ADDRESS] [varchar](50) NULL,
	[ADDRESS_NO] [varchar](10) NULL,
	[HOME_1] [varchar](10) NULL,
	[HOME_2] [varchar](10) NULL,
	[FULL_ADDRESS] [varchar](2000) NOT NULL,
	[HOME_PHONE] [varchar](20) NULL,
	[MOB_PHONE] [varchar](20) NULL,
	[FO_LAST_NAME] [varchar](50) NOT NULL,
	[FO_FIRST_NAME] [varchar](50) NOT NULL,
	[FO_FULL_NAME]  AS (([FO_LAST_NAME]+' ')+[FO_FIRST_NAME]),
	[FO_PASS_NO] [dbo].[TPID] NOT NULL,
	[MEMBERS_COUNT] [tinyint] NOT NULL,
	[FAMILY_PERSONS]  AS ([dbo].[fn_get_family_persons]([FID])),
	[REAL_FAMILY_PERSONS]  AS ([dbo].[fn_get_real_family_persons]([FID])),
	[FAMILY_SCORE] [int] NOT NULL,
	[CURRENT_DISB_MONEY] [money] NULL,
	[ACCRUAL_MONTH] [tinyint] NOT NULL,
	[PREPARE_DISB_MONTH] [tinyint] NOT NULL,
	[ON_CONTROL] [bit] NOT NULL,
	[SCORE_OLD] [int] NOT NULL,
	[SCORE_NEW] [int] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[FAMILY_SCORE_V2] [int] NULL,
	[LEGAL_SCORE_DATE] [smalldatetime] NOT NULL,
	[LEGAL_FAMILY_SCORE] [int] NOT NULL,
	[ACTIVE_VISIT_DATE] [smalldatetime] NOT NULL,
	[DOC_DATE] [datetime] NULL,
	[SCORE_BEFORE_RECALC] [int] NULL,
	[OQMI_DATE] [smalldatetime] NULL,
	[SCORE_BEFORE_OQMI] [int] NULL,
 CONSTRAINT [PK_FAMILY_DATA] PRIMARY KEY CLUSTERED 
(
	[FID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[FAMILY_DATA_20120801]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FAMILY_DATA_20120801](
	[FID] [dbo].[TFID] NOT NULL,
	[STATE] [tinyint] NOT NULL,
	[CALC_DATE] [smalldatetime] NULL,
	[ADT] [smalldatetime] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[SACODE] [int] NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [varchar](50) NULL,
	[REGION] [varchar](50) NULL,
	[GOVERNMENT] [varchar](50) NULL,
	[VILLAGE] [varchar](50) NULL,
	[ADDRESS] [varchar](50) NULL,
	[ADDRESS_NO] [varchar](10) NULL,
	[HOME_1] [varchar](10) NULL,
	[HOME_2] [varchar](10) NULL,
	[FULL_ADDRESS] [varchar](2000) NOT NULL,
	[HOME_PHONE] [varchar](20) NULL,
	[MOB_PHONE] [varchar](20) NULL,
	[FO_LAST_NAME] [varchar](50) NOT NULL,
	[FO_FIRST_NAME] [varchar](50) NOT NULL,
	[FO_FULL_NAME] [varchar](101) NOT NULL,
	[FO_PASS_NO] [dbo].[TPID] NOT NULL,
	[MEMBERS_COUNT] [tinyint] NOT NULL,
	[FAMILY_PERSONS] [nvarchar](1000) NULL,
	[REAL_FAMILY_PERSONS] [nvarchar](1000) NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[CURRENT_DISB_MONEY] [money] NULL,
	[ACCRUAL_MONTH] [tinyint] NOT NULL,
	[PREPARE_DISB_MONTH] [tinyint] NOT NULL,
	[ON_CONTROL] [bit] NOT NULL,
	[SCORE_OLD] [int] NOT NULL,
	[SCORE_NEW] [int] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[FAMILY_SCORE_V2] [int] NULL,
	[LEGAL_SCORE_DATE] [smalldatetime] NOT NULL,
	[LEGAL_FAMILY_SCORE] [int] NOT NULL,
	[ACTIVE_VISIT_DATE] [smalldatetime] NOT NULL,
	[DOC_DATE] [datetime] NULL,
	[SCORE_BEFORE_RECALC] [int] NULL,
	[OQMI_DATE] [smalldatetime] NULL,
	[SCORE_BEFORE_OQMI] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[HISTORY_LOG]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[HISTORY_LOG](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[OP_DATE] [smalldatetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[IDENTIFICATION_CRITERIA]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[IDENTIFICATION_CRITERIA](
	[CODE] [nvarchar](3) NULL,
	[CRITERIA] [nvarchar](255) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[JUST_CONDITIONS]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[JUST_CONDITIONS](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[VALID_FROM] [smalldatetime] NOT NULL,
	[ORDER] [int] NULL,
	[CONDITION_NAME] [nvarchar](150) NULL,
	[PERSON_STATE] [int] NULL,
	[CONDITION] [nvarchar](250) NULL,
	[DESCRIPTION] [nvarchar](250) NULL,
	[REC_DT] [smalldatetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[JUST_STATES_201204]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[JUST_STATES_201204](
	[STATUS_ID] [smallint] NULL,
	[STATUS_DESCRIPTION] [nvarchar](100) NULL,
	[CONDITION_ID] [bigint] NULL,
	[CONDITION_DESCRIPTION] [nvarchar](100) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_LOG]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_LOG](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[LOG_TIME] [smalldatetime] NOT NULL,
	[FROM_PROCEDURE] [nvarchar](50) NOT NULL,
	[COMMENT] [nvarchar](250) NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20120501]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20120501](
	[FID] [dbo].[TFID] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20120601]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20120601](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20120701]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20120701](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20120801]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20120801](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20120901]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20120901](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20121001]    Script Date: 10/04/2019 10:55:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20121001](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20121101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20121101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_201211_1]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_201211_1](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20121201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20121201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20121224]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20121224](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130301]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130301](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130401]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130401](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130501]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130501](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130601]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130601](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130701]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130701](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130801]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130801](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20130901]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20130901](
	[FID] [char](12) NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [char](4) NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20131001]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20131001](
	[FID] [char](12) NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [char](4) NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20131101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20131101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20131201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20131201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140103]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140103](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140301]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140301](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140401]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140401](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140501]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140501](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140601]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140601](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140701]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140701](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140801]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140801](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20140901]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20140901](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20141001]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20141001](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20141101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20141101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20141201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20141201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20150101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20150101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20150201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20150201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20150301]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20150301](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20150401]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20150401](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20150501]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20150501](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20150601]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20150601](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20150701]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20150701](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20150901]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20150901](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20151001]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20151001](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20151101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20151101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20151201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20151201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160301]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160301](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160401]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160401](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160501]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160501](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160601]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160601](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160701]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160701](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160801]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160801](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20160901]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20160901](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20161001]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20161001](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20161101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20161101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20161201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20161201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170301]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170301](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170401]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170401](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170501]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170501](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170601]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170601](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170701]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170701](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170801]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170801](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [varchar](50) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20170901]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20170901](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20171001]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20171001](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20171101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20171101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20171201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20171201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180301]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180301](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180401]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180401](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180501]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180501](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180601]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180601](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180701]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180701](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180801]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180801](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20180901]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20180901](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20181001]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20181001](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20181101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20181101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20181201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20181201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20190101]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20190101](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20190114]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20190114](
	[FID] [char](12) NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [char](4) NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20190201]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20190201](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_20190301]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_20190301](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_F]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_F](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LIVE_SCORES_F_20190114]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LIVE_SCORES_F_20190114](
	[FID] [char](12) NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [char](4) NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NULL,
	[AGE_CURRENT] [int] NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](250) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](255) NULL,
	[FID_VERSION] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[REG_RAI]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[REG_RAI](
	[RAI_ID] [float] NOT NULL,
	[REG_ID] [float] NULL,
	[RAION_ID] [nvarchar](255) NULL,
	[RAION_UTF] [nvarchar](255) NULL,
	[REGION_UTF] [nvarchar](255) NULL,
 CONSTRAINT [PK_REG_RAI] PRIMARY KEY CLUSTERED 
(
	[RAI_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[WORK_DECLARATION_FAMILY_QUEST_ARC]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WORK_DECLARATION_FAMILY_QUEST_ARC](
	[FID] [dbo].[TFID] NOT NULL,
	[DID] [int] NOT NULL,
	[ITEM_NO] [tinyint] NOT NULL,
	[QTYPE] [char](4) NOT NULL,
	[QID] [tinyint] NOT NULL,
	[QVALUE_TYPE] [varchar](50) NULL,
	[QVALUE_BIT] [bit] NULL,
	[QVALUE_INT] [int] NULL,
	[QVALUE_MONEY] [money] NULL,
	[QVALUE_TEXT] [varchar](255) NULL,
 CONSTRAINT [PK_WORK_DECLARATION_FAMILY_QUEST_ARC] PRIMARY KEY CLUSTERED 
(
	[DID] ASC,
	[ITEM_NO] ASC,
	[QTYPE] ASC,
	[QID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[WORK_DECLARATION_FAMILY_QUEST_V2_ARC]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WORK_DECLARATION_FAMILY_QUEST_V2_ARC](
	[FID] [dbo].[TFID] NOT NULL,
	[DID] [int] NOT NULL,
	[ITEM_NO] [tinyint] NOT NULL,
	[QTYPE] [char](4) NOT NULL,
	[QID] [tinyint] NOT NULL,
	[QVALUE_TYPE] [varchar](50) NULL,
	[QVALUE_BIT] [bit] NULL,
	[QVALUE_INT] [int] NULL,
	[QVALUE_MONEY] [money] NULL,
	[QVALUE_TEXT] [varchar](255) NULL,
 CONSTRAINT [PK_WORK_DECLARATION_FAMILY_QUEST_V2_ARC] PRIMARY KEY CLUSTERED 
(
	[DID] ASC,
	[ITEM_NO] ASC,
	[QTYPE] ASC,
	[QID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[WORK_DECLARATION_QUEST_ARC]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WORK_DECLARATION_QUEST_ARC](
	[FID] [dbo].[TFID] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[QTYPE] [char](4) NOT NULL,
	[QID] [tinyint] NOT NULL,
	[QVALUE_TYPE] [varchar](10) NOT NULL,
	[QVALUE_BIT] [bit] NULL,
	[QVALUE_INT] [int] NULL,
	[QVALUE_MONEY] [money] NULL,
	[QVALUE_TEXT] [varchar](255) NULL,
 CONSTRAINT [PK_WORK_DECLARATION_QUEST_ARC] PRIMARY KEY CLUSTERED 
(
	[REC_ID] ASC,
	[QTYPE] ASC,
	[QID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[WORK_DECLARATION_QUEST_V2_ARC]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WORK_DECLARATION_QUEST_V2_ARC](
	[FID] [dbo].[TFID] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[QTYPE] [char](4) NOT NULL,
	[QID] [tinyint] NOT NULL,
	[QVALUE_TYPE] [varchar](10) NOT NULL,
	[QVALUE_BIT] [bit] NULL,
	[QVALUE_INT] [int] NULL,
	[QVALUE_MONEY] [money] NULL,
	[QVALUE_TEXT] [varchar](255) NULL,
 CONSTRAINT [PK_WORK_DECLARATION_QUEST_V2_ARC] PRIMARY KEY CLUSTERED 
(
	[REC_ID] ASC,
	[QTYPE] ASC,
	[QID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  View [dbo].[FAMILY_DATA_PERSONS]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[FAMILY_DATA_PERSONS]
AS
SELECT dbo.DECLARATION_FAMILY_V1V2_ARC.*
FROM dbo.DECLARATION_FAMILY_V1V2_ARC
GO
/****** Object:  View [dbo].[VW_LIVE_SCORES_F]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE VIEW [dbo].[VW_LIVE_SCORES_F]
AS
SELECT F.[FID]
      ,F.[SOURCE]
      ,F.[REC_ID]
      ,F.[ITEM_NO]
      ,F.[FAMILY_SCORE]
      ,F.[REGION_ID]
      ,F.[REGION]
      ,F.[ZIP_CODE]
      ,F.[CITY]
      ,F.[GOVERNMENT]
      ,F.[VILLAGE]
      ,F.[FULL_ADDRESS]
      ,F.[PID]
      ,F.[BIRTH_DATE]
      ,F.[FIRST_NAME]
      ,F.[LAST_NAME]
      ,F.[AGE]
      ,F.[SEX]
      ,F.[ACTION_CODE]
      ,F.[ACTION_DATE]
      ,F.[SCORE_DATE]
      ,F.[VISIT_DATE]
      ,F.[PERSON_STATE]
      ,F.[DOC_STATE]
      ,F.[STATUS_ID]
      ,F.[CONDITION_ID]
      ,F.[IDENT]
      ,F.[SRA_ID]
      ,F.[RESORE_DOC_NO]
      ,F.[RESTORE_DOC_DATE]
      ,case when B.[MONEY]=12 then NULL else B.[MONEY] END as [MONEY] 
	  ,F.[FO_PASS_ID]
	  ,F.[FO_FULL_NAME]
	  ,F.[PHONES]
	  ,F.FID_VERSION
	  ,C.REGION_UTF as REGION_NAME

	  ,D.PID as MONEY_RECIEVER_PID
	  ,D.LAST_NAME as MONEY_RECIEVER_LAST_NAME
	  ,D.FIRST_NAME as MONEY_RECIEVER_FIRST_NAME
	  ,D.BIRTH_DATE as MONEY_RECIEVER_BIRTH_DATE

  FROM [dbo].[LIVE_SCORES_F] F with (NOLOCK)
  inner join REG_RAI C on C.RAI_ID = F.REGION_ID
  left join SAESA2005..SOCIAL_PRC_TANXIS_MIMGEBI D on D.FID = F.FID
  left join SAESA2005..SOCIAL_PRC_BANK_NEW B on B.FID=F.FID
  
  where ACTION_CODE is null or ACTION_CODE = '100'

GO
/****** Object:  View [dbo].[VW_LIVE_SCORES_F_V01]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO








CREATE VIEW [dbo].[VW_LIVE_SCORES_F_V01]
AS
SELECT F.[FID]
      ,F.[SOURCE]
      ,F.[REC_ID]
      ,F.[ITEM_NO]
      ,F.[FAMILY_SCORE]
      ,F.[REGION_ID]
      ,F.[REGION]
      ,F.[ZIP_CODE]
      ,F.[CITY]
      ,F.[GOVERNMENT]
      ,F.[VILLAGE]
      ,F.[FULL_ADDRESS]
      ,F.[PID]
      ,F.[BIRTH_DATE]
      ,F.[FIRST_NAME]
      ,F.[LAST_NAME]
      ,F.[AGE]
      ,F.[SEX]
      ,F.[ACTION_CODE]
      ,F.[ACTION_DATE]
      ,F.[SCORE_DATE]
      ,F.[VISIT_DATE]
      ,F.[PERSON_STATE]
      ,F.[DOC_STATE]
      ,F.[STATUS_ID]
      ,F.[CONDITION_ID]
      ,F.[IDENT]
      ,F.[SRA_ID]
      ,F.[RESORE_DOC_NO]
      ,F.[RESTORE_DOC_DATE]
      ,case when B.[MONEY]=12 then NULL else B.[MONEY] END as [MONEY] 
	  ,F.[FO_PASS_ID]
	  ,F.[FO_FULL_NAME]
	  ,F.[PHONES]
	  ,F.FID_VERSION
	  ,C.REGION_UTF as REGION_NAME
	  ,D.PID as MONEY_RECIEVER_PID
	  ,D.LAST_NAME as MONEY_RECIEVER_LAST_NAME
	  ,D.FIRST_NAME as MONEY_RECIEVER_FIRST_NAME
	  ,D.BIRTH_DATE as MONEY_RECIEVER_BIRTH_DATE
  FROM [dbo].[LIVE_SCORES_F] F with (NOLOCK)
  inner join REG_RAI C on C.RAI_ID = F.REGION_ID
  left join SAESA2005..SOCIAL_PRC_TANXIS_MIMGEBI D on D.FID = F.FID
  left join SAESA2005..SOCIAL_PRC_BANK_NEW B on B.FID=F.FID
  
  where ACTION_CODE is null or ACTION_CODE = '100'





GO
/****** Object:  View [dbo].[WEB_PERSON_IN_FIDS]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



CREATE VIEW [dbo].[WEB_PERSON_IN_FIDS]
AS
select A.FID, A.PID as PID, dbo.fn_con2utf8(A.FIRST_NAME) as FIRST_NAME, dbo.fn_con2utf8(A.LAST_NAME) as  LAST_NAME, 
A.BIRTH_DATE, dbo.fn_con2utf8(A.FULL_ADDRESS) as FULL_ADDRESS, 
A.ACTION_CODE, A.ACTION_DATE, A.VISIT_DATE, A.FAMILY_SCORE as LEGAL_FAMILY_SCORE , 0 as FID_VERSION,  0 as ON_CONTROL
   from LIVE_SCORES_F A


GO
SET ANSI_PADDING ON
GO
/****** Object:  Index [IX_LIVE_SCORES_F]    Script Date: 10/04/2019 10:56:00 ******/
CREATE NONCLUSTERED INDEX [IX_LIVE_SCORES_F] ON [dbo].[LIVE_SCORES_F]
(
	[FID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object:  Index [IX_LIVE_SCORES_F_1]    Script Date: 10/04/2019 10:56:00 ******/
CREATE NONCLUSTERED INDEX [IX_LIVE_SCORES_F_1] ON [dbo].[LIVE_SCORES_F]
(
	[PID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_LIVE_SCORES_F_2]    Script Date: 10/04/2019 10:56:00 ******/
CREATE NONCLUSTERED INDEX [IX_LIVE_SCORES_F_2] ON [dbo].[LIVE_SCORES_F]
(
	[REC_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE [dbo].[JUST_CONDITIONS] ADD  CONSTRAINT [DF_JUST_CONDITIONS_REC_DT]  DEFAULT (getdate()) FOR [REC_DT]
GO
ALTER TABLE [dbo].[LIVE_LOG] ADD  CONSTRAINT [DF_LIVE_LOG_LOG_TIME]  DEFAULT (getdate()) FOR [LOG_TIME]
GO
/****** Object:  StoredProcedure [dbo].[ERASE_LIVE_SCORES_F]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[ERASE_LIVE_SCORES_F] 

AS
BEGIN
/*
DROP INDEX [IX_LIVE_SCORES_F] ON [dbo].[LIVE_SCORES_F]
DROP INDEX [IX_LIVE_SCORES_F_1] ON [dbo].[LIVE_SCORES_F]
DROP INDEX [IX_LIVE_SCORES_F_2] ON [dbo].[LIVE_SCORES_F]
*/

DROP TABLE [dbo].[LIVE_SCORES_F]

SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

SET ANSI_PADDING ON

CREATE TABLE [dbo].[LIVE_SCORES_F](
	[FID] [dbo].[TFID] NOT NULL,
	[SOURCE] [int] NOT NULL,
	[REC_ID] [int] NOT NULL,
	[ITEM_NO] [int] NOT NULL,
	[FAMILY_SCORE] [int] NOT NULL,
	[REGION_ID] [int] NOT NULL,
	[REGION] [nvarchar](50) NOT NULL,
	[ZIP_CODE] [dbo].[TZIP_CODE] NOT NULL,
	[CITY] [nvarchar](50) NULL,
	[GOVERNMENT] [nvarchar](50) NULL,
	[VILLAGE] [nvarchar](50) NULL,
	[FULL_ADDRESS] [nvarchar](255) NULL,
	[PID] [nvarchar](50) NOT NULL,
	[BIRTH_DATE] [smalldatetime] NOT NULL,
	[FIRST_NAME] [nvarchar](50) NOT NULL,
	[LAST_NAME] [nvarchar](50) NOT NULL,
	[AGE] [int] NOT NULL,
	[SEX] [smallint] NOT NULL,
	[ACTION_CODE] [int] NULL,
	[ACTION_DATE] [smalldatetime] NULL,
	[SCORE_DATE] [smalldatetime] NOT NULL,
	[VISIT_DATE] [smalldatetime] NOT NULL,
	[PERSON_STATE] [int] NULL,
	[DOC_STATE] [int] NULL,
	[STATUS_ID] [int] NULL,
	[CONDITION_ID] [int] NULL,
	[IDENT] [int] NULL,
	[SRA_ID] [int] NULL,
	[RESORE_DOC_NO] [nvarchar](255) NULL,
	[RESTORE_DOC_DATE] [smalldatetime] NULL,
	[FO_PASS_ID] [char](11) NULL,
	[FO_FULL_NAME] [nvarchar](101) NULL,
	[PHONES] [nvarchar](250) NULL
) ON [PRIMARY]


SET ANSI_PADDING OFF


CREATE NONCLUSTERED INDEX [IX_LIVE_SCORES_F] ON [dbo].[LIVE_SCORES_F]
(
	[FID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]



CREATE NONCLUSTERED INDEX [IX_LIVE_SCORES_F_1] ON [dbo].[LIVE_SCORES_F]
(
	[PID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]



CREATE NONCLUSTERED INDEX [IX_LIVE_SCORES_F_2] ON [dbo].[LIVE_SCORES_F]
(
	[REC_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'LIVE_SCORES_F RECREATED'

END
GO
/****** Object:  StoredProcedure [dbo].[FILL_LIVE_SCORES_2]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[FILL_LIVE_SCORES_2] 

AS
BEGIN

	SET NOCOUNT ON;
	
	print 0
    print CURRENT_TIMESTAMP 
      
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'*BEGIN'
   
    exec SAESA2005.dbo.FILL_FROM_SASEA2005_PART_1

    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'*end of FILL_FROM_SASEA2005_PART_1'
    

	DECLARE @GETDATE DATETIME

	DECLARE @TA TABLE (FID TFID, FID_VERSION INT, SOURCE INT, REC_ID INT, RESORE_DOC_NO NVARCHAR(255), RESTORE_DOC_DATE SMALLDATETIME,
				   FO_PASS_ID NVARCHAR(50), FO_FULL_NAME NVARCHAR(101), PHONES NVARCHAR(250))

	SET @GETDATE = GETDATE()

-- aqaa DROP AND RECREATE tavis Indexebit
--	EXECUTE [dbo].[ERASE_LIVE_SCORES_F] 

--	delete [dbo].[LIVE_SCORES_F]
--	exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'LIVE_SCORES_F DELETED'

	TRUNCATE TABLE [dbo].[LIVE_SCORES_F]
	exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'LIVE_SCORES_F TRUNCATED'
	
	/****** GADAKETDA TRUNCATE TABLE 09/04/2016 - ZURA *****/
	--delete [dbo].[WORK_DECLARATION_FAMILY_QUEST_ARC]
	--delete [dbo].[WORK_DECLARATION_FAMILY_QUEST_V2_ARC]
	--delete [dbo].[WORK_DECLARATION_QUEST_ARC] 
	--delete [dbo].[WORK_DECLARATION_QUEST_V2_ARC] 

	/****** ES ARAVIS AGAR CHIRDEBA (GUBELIDZE) DA AGAR SHEIVSEBA 11/04/2016 - ZURA *****/
	--TRUNCATE TABLE  [dbo].[WORK_DECLARATION_FAMILY_QUEST_ARC]
	--TRUNCATE TABLE  [dbo].[WORK_DECLARATION_FAMILY_QUEST_V2_ARC]
	--TRUNCATE TABLE  [dbo].[WORK_DECLARATION_QUEST_ARC] 
	--TRUNCATE TABLE  [dbo].[WORK_DECLARATION_QUEST_V2_ARC] 	


	/****** ES ARAVIS AGAR CHIRDEBA DA AGAR SHEIVSEBA 08/04/2016 - ZURA *****/
	--delete [dbo].[DECLARATION_QUEST_V1V2_ARC] 
	--delete [dbo].[DECLARATION_FAMILY_QUEST_V1V2_ARC]
	--delete [dbo].[DECLARATION_FAMILY_V1V2_ARC]  
	--delete [dbo].[DECLARATIONS_V1V2_ARC]
	
	/****** ES ARAVIS AGAR CHIRDEBA 08/04/2016 - ZURA *****/
	--TRUNCATE TABLE  [dbo].[DECLARATION_QUEST_V1V2_ARC] 
	--TRUNCATE TABLE  [dbo].[DECLARATION_FAMILY_QUEST_V1V2_ARC]
	--TRUNCATE TABLE  [dbo].[DECLARATION_FAMILY_V1V2_ARC]  
	--TRUNCATE TABLE  [dbo].[DECLARATIONS_V1V2_ARC]		

			
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP 1 D_ARC-s'
	INSERT INTO [dbo].[LIVE_SCORES_F]
			   ([FID]
			   ,[SOURCE]
			   ,[REC_ID] 
			   ,[ITEM_NO]
			   ,[FAMILY_SCORE]
			   ,[REGION_ID]
			   ,[REGION] 
			   ,[ZIP_CODE]
			   ,[CITY]
			   ,[GOVERNMENT]
			   ,[VILLAGE]
			   ,[FULL_ADDRESS]
			   ,[PID]
			   ,[BIRTH_DATE]
			   ,[FIRST_NAME]
			   ,[LAST_NAME]
			   ,[AGE]
			   ,[AGE_CURRENT]
			   ,[SEX] 
			   ,[ACTION_CODE]
			   ,[ACTION_DATE]
			   ,[SCORE_DATE]
			   ,[VISIT_DATE]
			   ,[RESORE_DOC_NO]
			   ,[RESTORE_DOC_DATE]
			   ,[IDENT] 
			   ,[SRA_ID]
			   ,[FO_PASS_ID] 
			   ,[FO_FULL_NAME] 
			   ,[PHONES]
			   ,[FID_VERSION])
	  select F.FID,
	     1,  
	     D.REC_ID,
	     P.ITEM_NO,
		 F.LEGAL_FAMILY_SCORE, 
		 F.REGION_ID, 
		 dbo.fn_con2utf8(F.REGION), 
		 F.ZIP_CODE, 
		 dbo.fn_con2utf8(F.CITY), 
		 dbo.fn_con2utf8(F.GOVERNMENT), 
		 dbo.fn_con2utf8(F.VILLAGE), 
		 dbo.fn_con2utf8(F.FULL_ADDRESS), 
		 P.PASS_ID as PID, 
		 P.BIRTH_DATE, 
		 dbo.fn_con2utf8(P.FIRST_NAME), 
		 dbo.fn_con2utf8(P.LAST_NAME), 
		 P.AGE,
		 dbo.FN_GET_PERSON_AGE(BIRTH_DATE, @GETDATE),
		 P.SEX,
		 P.ACTION_TYPE,
		 P.ACTION_DATE,
		 F.LEGAL_SCORE_DATE, 
		 F.VISIT_DATE,
		 F.RESORE_DOC_NO,
		 F.RESTORE_DOC_DATE, 
		 P.PIROBA,
		 P.J_ID,
		 D.FO_PASS_ID,
		 dbo.fn_con2utf8(F.FO_FULL_NAME),
		 dbo.fn_con2utf8(ISNULL(N'სახლი:' + F.HOME_PHONE + '; ','') + ISNULL(N'მობ:' + F.MOB_PHONE + ';','')),
		 0
	  from [SAESA2005].[dbo].FAMILY_DATA F
		inner join [SAESA2005].[dbo].FAMILY_DATA_PERSONS P on F.FID=P.FID
		inner join [SAESA2005].[dbo].DECLARATIONS_ARC D on D.FID=F.FID and D.REC_VERSION=3
		where (ON_CONTROL=0) 
		  --and  ((LEGAL_SCORE_DATE <= GETDATE()) or (F.OQMI_DATE is not null) or (F.DOC_DATE is not null)) 
		  --and (F.LEGAL_FAMILY_SCORE <70001)
		  --and (P.ACTION_TYPE is null or P.ACTION_TYPE='100') 
	
	
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP 1 D_V2_ARC-s'
	INSERT INTO [dbo].[LIVE_SCORES_F]
			   ([FID]
			   ,[SOURCE] 
			   ,[REC_ID] 
			   ,[ITEM_NO]
			   ,[FAMILY_SCORE]
			   ,[REGION_ID]
			   ,[REGION] 
			   ,[ZIP_CODE]
			   ,[CITY]
			   ,[GOVERNMENT]
			   ,[VILLAGE]
			   ,[FULL_ADDRESS]
			   ,[PID]
			   ,[BIRTH_DATE]
			   ,[FIRST_NAME]
			   ,[LAST_NAME]
			   ,[AGE] 
			   ,[AGE_CURRENT]
			   ,[SEX] 
			   ,[ACTION_CODE]
			   ,[ACTION_DATE]
			   ,[SCORE_DATE]
			   ,[VISIT_DATE]
			   ,[RESORE_DOC_NO]
			   ,[RESTORE_DOC_DATE]
			   ,[IDENT] 
			   ,[SRA_ID]
			   ,[FO_PASS_ID] 
			   ,[FO_FULL_NAME] 
			   ,[PHONES]
			   ,[FID_VERSION])
	  select F.FID, 
	     2,
	     D.REC_ID,
	     P.ITEM_NO,
		 F.LEGAL_FAMILY_SCORE, 
		 F.REGION_ID, 
		 dbo.fn_con2utf8(F.REGION), 
		 F.ZIP_CODE, 
		 dbo.fn_con2utf8(F.CITY), 
		 dbo.fn_con2utf8(F.GOVERNMENT), 
		 dbo.fn_con2utf8(F.VILLAGE), 
		 dbo.fn_con2utf8(F.FULL_ADDRESS), 
		 P.PASS_ID as PID, 
		 P.BIRTH_DATE, 
		 dbo.fn_con2utf8(P.FIRST_NAME), 
		 dbo.fn_con2utf8(P.LAST_NAME), 
		 P.AGE,
		 dbo.FN_GET_PERSON_AGE(BIRTH_DATE, @GETDATE),
		 P.SEX,
		 P.ACTION_TYPE,
		 P.ACTION_DATE,
		 CASE WHEN /*(F.OQMI_DATE is NULL) and*/ (F.LEGAL_SCORE_DATE < @GETDATE ) --CURRENT_TIMESTAMP) -- ZURA 19/05/2016
		    THEN F.LEGAL_SCORE_DATE 
		    ELSE DATEADD(D, 30, F.VISIT_DATE) 
		       /*CASE WHEN (F.OQMI_DATE NOT NULL) 
		          THEN DATEADD(D, 30, F.VISIT_DATE) 
		          ELSE DATEADD(D, 30, F.VISIT_DATE) */		          
		 END as LEGAL_SCORE_DATE,  

		 F.VISIT_DATE,
		 F.RESORE_DOC_NO,
		 F.RESTORE_DOC_DATE, 
		 P.PIROBA,
		 P.J_ID,
		 D.FO_PID,
		 dbo.fn_con2utf8(F.FO_FULL_NAME),
		 dbo.fn_con2utf8(ISNULL(N'სახლი:' + F.HOME_PHONE + '; ','') + ISNULL(N'მობ:' + F.MOB_PHONE + ';','')),
		 0
	  from [SAESA2005].[dbo].FAMILY_DATA F
		inner join [SAESA2005].[dbo].FAMILY_DATA_PERSONS P on F.FID=P.FID
		inner join [SAESA2005].[dbo].DECLARATIONS_V2_ARC D on D.FID=F.FID and D.REC_VERSION=3
  		where (ON_CONTROL=0) 
		  and  (
				[SAESA2005].[dbo].[ALLOW_GET_FROM_FAMILY_DATA] (F.FID, F.FAMILY_SCORE, F.VISIT_DATE, F.DOC_DATE, F.SCORE_BEFORE_RECALC, F.OQMI_DATE, F.SCORE_BEFORE_OQMI ) = 1
			-- ZURA     (LEGAL_SCORE_DATE <= GETDATE()) 
		      --  or (F.OQMI_DATE is not null) 
		     --  or ((F.DOC_DATE is not null) and (DATEADD(D, 30, F.VISIT_DATE) < GETDATE()))
				)
		  --and (F.LEGAL_FAMILY_SCORE <70001)
		  --and (P.ACTION_TYPE is null or P.ACTION_TYPE='100') 	 
		      
	exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP 1 D_V3_ARC-s'
	INSERT INTO [dbo].[LIVE_SCORES_F]
			   ([FID]
			   ,[SOURCE] 
			   ,[REC_ID] 
			   ,[ITEM_NO]
			   ,[FAMILY_SCORE]
			   ,[REGION_ID]
			   ,[REGION] 
			   ,[ZIP_CODE]
			   ,[CITY]
			   ,[GOVERNMENT]
			   ,[VILLAGE]
			   ,[FULL_ADDRESS]
			   ,[PID]
			   ,[BIRTH_DATE]
			   ,[FIRST_NAME]
			   ,[LAST_NAME]
			   ,[AGE] 
			   ,[AGE_CURRENT]
			   ,[SEX] 
			   ,[ACTION_CODE]
			   ,[ACTION_DATE]
			   ,[SCORE_DATE]
			   ,[VISIT_DATE]
			   ,[RESORE_DOC_NO]
			   ,[RESTORE_DOC_DATE]
			   ,[IDENT] 
			   ,[SRA_ID]
			   ,[FO_PASS_ID] 
			   ,[FO_FULL_NAME] 
			   ,[PHONES]
			   ,[FID_VERSION])
	  select F.FID, 
	     5,
	     D.REC_ID,
	     P.ITEM_NO,
		 F.LEGAL_FAMILY_SCORE, 
		 F.REGION_ID, 
		 dbo.fn_con2utf8(F.REGION), 
		 F.ZIP_CODE, 
		 dbo.fn_con2utf8(F.CITY), 
		 dbo.fn_con2utf8(F.GOVERNMENT), 
		 dbo.fn_con2utf8(F.VILLAGE), 
		 dbo.fn_con2utf8(F.FULL_ADDRESS), 
		 P.PASS_ID as PID, 
		 P.BIRTH_DATE, 
		 dbo.fn_con2utf8(P.FIRST_NAME), 
		 dbo.fn_con2utf8(P.LAST_NAME), 
		 P.AGE,
		 dbo.FN_GET_PERSON_AGE(BIRTH_DATE, @GETDATE),
		 P.SEX,
		 P.ACTION_TYPE,
		 P.ACTION_DATE,
		 CASE WHEN /*(F.OQMI_DATE is NULL) and*/ (F.LEGAL_SCORE_DATE < @GETDATE ) --CURRENT_TIMESTAMP) -- ZURA 19/05/2016
		    THEN F.LEGAL_SCORE_DATE 
		    ELSE DATEADD(D, 30, F.VISIT_DATE) 
		       /*CASE WHEN (F.OQMI_DATE NOT NULL) 
		          THEN DATEADD(D, 30, F.VISIT_DATE) 
		          ELSE DATEADD(D, 30, F.VISIT_DATE) */		          
		 END as LEGAL_SCORE_DATE,  

		 F.VISIT_DATE,
		 F.RESORE_DOC_NO,
		 F.RESTORE_DOC_DATE, 
		 P.PIROBA,
		 P.J_ID,
		 D.FO_PID,
		 dbo.fn_con2utf8(F.FO_FULL_NAME),
		 dbo.fn_con2utf8(ISNULL(N'სახლი:' + F.HOME_PHONE + '; ','') + ISNULL(N'მობ:' + F.MOB_PHONE + ';','')),
		 0
	  from [SAESA2005].[dbo].FAMILY_DATA F
		inner join [SAESA2005].[dbo].FAMILY_DATA_PERSONS P on F.FID=P.FID
		inner join [SAESA2005].[dbo].DECLARATIONS_V3_ARC D on D.FID=F.FID and D.REC_VERSION=3
		where (ON_CONTROL=0) 
		   and  (
		   	[SAESA2005].[dbo].[ALLOW_GET_FROM_FAMILY_DATA] (F.FID, F.FAMILY_SCORE, F.VISIT_DATE, F.DOC_DATE, F.SCORE_BEFORE_RECALC, F.OQMI_DATE, F.SCORE_BEFORE_OQMI ) = 1
			-- ZURA 	   (LEGAL_SCORE_DATE <= GETDATE()) 
		      --  or (F.OQMI_DATE is not null) 
		     --  or ((F.DOC_DATE is not null) and (DATEADD(D, 30, F.VISIT_DATE) < GETDATE()))
				)
		  --and (F.LEGAL_FAMILY_SCORE <70001)
		  --and (P.ACTION_TYPE is null or P.ACTION_TYPE='100') 	 
		   
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP 2 D_HIST-s'
	INSERT INTO @TA (FID, FID_VERSION, SOURCE, REC_ID, RESORE_DOC_NO, RESTORE_DOC_DATE, 
		FO_PASS_ID, FO_FULL_NAME, PHONES)
	  select D.FID, D.FID_VERSION, 3, D.REC_ID, FD.RESORE_DOC_NO, FD.RESTORE_DOC_DATE,
		 D.FO_PASS_ID,
		 dbo.fn_con2utf8(FD.FO_FULL_NAME),
		 dbo.fn_con2utf8(ISNULL(N'სახლი:' + FD.HOME_PHONE + '; ','') + ISNULL(N'მობ:' + FD.MOB_PHONE+ ';',''))
	   from [SAESA2005].[dbo].DECLARATIONS_HISTORY D 
		inner join [SAESA2005].[dbo].FAMILY_DATA_HISTORY FD on D.FID=FD.FID and FD.FID_VERSION=D.FID_VERSION
		left outer join [SAESA2005].[dbo].FORM_3 F3 on F3.FID=D.FID
		LEFT outer join [dbo].[LIVE_SCORES_F] AC on AC.FID=D.FID
		where ((D.ADD_DATE > @GETDATE /* GETDATE()  -- ZURA 19/05/2016 */ -26) or 
			EXISTS(SELECT NULL FROM [SAESA2005].[dbo].FAMILY_DATA R WHERE (R.FID=D.FID) and 
				((LEGAL_SCORE_DATE > @GETDATE /* GETDATE()  -- ZURA 19/05/2016 */ ) or (R.ON_CONTROL = 1))))
		  and (D.REC_VERSION=3) 
		  and (FD.ON_CONTROL=0)
		  and (F3.FID is NULL)
		  and (AC.FID is NULL)

    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP 2 D_V2_HIST-s'
	INSERT INTO @TA (FID, FID_VERSION, SOURCE,REC_ID, RESORE_DOC_NO, RESTORE_DOC_DATE,
			FO_PASS_ID, FO_FULL_NAME, PHONES)
	  select D.FID, D.FID_VERSION, 4, D.REC_ID, FD.RESORE_DOC_NO, FD.RESTORE_DOC_DATE,
	     D.FO_PID, --  FO_PASS_ID,
		 dbo.fn_con2utf8(FD.FO_FULL_NAME),
		 dbo.fn_con2utf8(ISNULL(N'სახლი:' + FD.HOME_PHONE + '; ','') + ISNULL(N'მობ:' + FD.MOB_PHONE+ ';',''))
	   from [SAESA2005].[dbo].DECLARATIONS_V2_HISTORY D 
		inner join [SAESA2005].[dbo].FAMILY_DATA_HISTORY FD on D.FID=FD.FID and FD.FID_VERSION=D.FID_VERSION
		left outer join [SAESA2005].[dbo].FORM_3 F3 on F3.FID=D.FID
		LEFT outer join [dbo].[LIVE_SCORES_F] AC 
		   on AC.FID=D.FID
		where ((D.ADD_DATE > @GETDATE /* GETDATE()  -- ZURA 19/05/2016 */ -26) or 
			EXISTS(SELECT NULL FROM [SAESA2005].[dbo].FAMILY_DATA R WHERE (R.FID=D.FID) and 
				((LEGAL_SCORE_DATE > @GETDATE /* GETDATE()  -- ZURA 19/05/2016 */ ) or (R.ON_CONTROL = 1))))
		  and (D.REC_VERSION=3) 
		  and (FD.ON_CONTROL=0)
		  and (F3.FID is NULL)
		  and (AC.FID is NULL)

	exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP 2 D_V3_HIST-s'
	INSERT INTO @TA (FID, FID_VERSION, SOURCE,REC_ID, RESORE_DOC_NO, RESTORE_DOC_DATE,
			FO_PASS_ID, FO_FULL_NAME, PHONES)
	  select D.FID, D.FID_VERSION, 6, D.REC_ID, FD.RESORE_DOC_NO, FD.RESTORE_DOC_DATE,
	  	 D.FO_PID, --  FO_PASS_ID,
		 dbo.fn_con2utf8(FD.FO_FULL_NAME),
		 dbo.fn_con2utf8(ISNULL(N'სახლი:' + FD.HOME_PHONE + '; ','') + ISNULL(N'მობ:' + FD.MOB_PHONE+ ';',''))
	   from [SAESA2005].[dbo].DECLARATIONS_V3_HISTORY D 
		inner join [SAESA2005].[dbo].FAMILY_DATA_HISTORY FD on D.FID=FD.FID and FD.FID_VERSION=D.FID_VERSION
		left outer join [SAESA2005].[dbo].FORM_3 F3 on F3.FID=D.FID
		LEFT outer join [dbo].[LIVE_SCORES_F] AC on AC.FID=D.FID
		where ((D.ADD_DATE >  @GETDATE /* GETDATE()  -- ZURA 19/05/2016 */  -26) or 
			EXISTS(SELECT NULL FROM [SAESA2005].[dbo].FAMILY_DATA R WHERE (R.FID=D.FID) and 
				((LEGAL_SCORE_DATE >  @GETDATE /* GETDATE()  -- ZURA 19/05/2016 */ ) or (R.ON_CONTROL = 1))))
		  and (D.REC_VERSION=3) 
		  and (FD.ON_CONTROL=0)
		  and (F3.FID is NULL)
		  and (AC.FID is NULL)
	
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP 2 D_HIST_ALL insert from TEMP_TABLE'
	INSERT INTO [dbo].[LIVE_SCORES_F]
			   ([FID]
			   ,[SOURCE] 
			   ,[REC_ID]	
			   ,[ITEM_NO]
			   ,[FAMILY_SCORE]
			   ,[REGION_ID]
			   ,[REGION] 
			   ,[ZIP_CODE]
			   ,[CITY]
			   ,[GOVERNMENT]
			   ,[VILLAGE]
			   ,[FULL_ADDRESS]
			   ,[PID]
			   ,[BIRTH_DATE]
			   ,[FIRST_NAME]
			   ,[LAST_NAME]
			   ,[AGE]
			   ,[AGE_CURRENT]
			   ,[SEX] 
			   ,[ACTION_CODE]
			   ,[ACTION_DATE]
			   ,[SCORE_DATE]
			   ,[VISIT_DATE]
			   ,[RESORE_DOC_NO]
			   ,[RESTORE_DOC_DATE]
			   ,[IDENT] 
			   ,[SRA_ID]
			   ,[FO_PASS_ID] 
			   ,[FO_FULL_NAME] 
			   ,[PHONES]
			   ,[FID_VERSION])
	  select F.FID, 
	     T.SOURCE,
	     T.REC_ID,
	     P.ITEM_NO,
		 F.FAMILY_SCORE, 
		 F.REGION_ID, 
		 dbo.fn_con2utf8(F.REGION), 
		 F.ZIP_CODE, 
		 dbo.fn_con2utf8(F.CITY), 
		 dbo.fn_con2utf8(F.GOVERNMENT), 
		 dbo.fn_con2utf8(F.VILLAGE), 
		 dbo.fn_con2utf8(F.FULL_ADDRESS), 
		 P.PASS_ID as PID, 
		 P.BIRTH_DATE, 
		 dbo.fn_con2utf8(P.FIRST_NAME), 
		 dbo.fn_con2utf8(P.LAST_NAME), 
		 P.AGE,
		 dbo.FN_GET_PERSON_AGE(BIRTH_DATE, @GETDATE),
		 P.SEX,
		 P.ACTION_TYPE,
		 P.ACTION_DATE,
		 F.LEGAL_SCORE_DATE, 
		 F.VISIT_DATE,
		 T.RESORE_DOC_NO,
		 T.RESTORE_DOC_DATE, 
		 P.PIROBA,
		 P.J_ID,
		 T.FO_PASS_ID,
		 T.FO_FULL_NAME,
		 T.PHONES,
		 F.FID_VERSION
	   from [SAESA2005].[dbo].FAMILY_DATA_HISTORY F
		inner join [SAESA2005].[dbo].FAMILY_DATA_PERSONS_HISTORY P on (P.FID=F.FID) and (P.FID_VERSION=F.FID_VERSION)
		inner join @TA T on (T.FID=F.FID) and (T.FID_VERSION=F.FID_VERSION)
		where (F.ON_CONTROL=0)
		  and (F.LEGAL_SCORE_DATE <=  @GETDATE /* GETDATE()  -- ZURA 19/05/2016 */ ) 
		  --and (F.FAMILY_SCORE <70001)
		  --and (P.ACTION_TYPE is null or P.ACTION_TYPE='100')
		  and F.FID_VERSION=(select maX(FID_VERSION) from @TA TT where (TT.FID=F.FID) and (ON_CONTROL=0))

---- JUST ----
	exec SP_ADD_LOG N'[JUST]', N'JUST GEO_CITIZEN_LOST'		-- მოქალაქეობის დაკარგვა
	update [LIVE_SCORES_F] set PERSON_STATE = 444 
	from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_JUST_SDB J on J.PID=A.PID collate Latin1_General_BIN 
	where  (J.IS_GEO_CITIZEN = 0 AND J.DOC_STATUS = 2 )
            AND ( J.GEO_CITIZEN_LOST_TYPE in (1, 2))

    
	exec SP_ADD_LOG N'[JUST]', N'JUST ABOARD'				-- საზღვარგარეთ მუდმივ საცხოვრებლად წასვლა
	update [LIVE_SCORES_F] set PERSON_STATE = 333 
	from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_JUST_SDB J on J.PID = A.PID collate Latin1_General_BIN
	WHERE   J.IS_LIVING_ABOARD > 0 


	exec SP_ADD_LOG N'[JUST]', N'JUST PRISIONERS'			-- პატიმრობა
	update [LIVE_SCORES_F] set PERSON_STATE = 999 
	from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_JUST_SDB J on J.PID=A.PID collate Latin1_General_BIN
	where J.P_PRISIONER_STATUS in (1, 2)
					AND A.PID not in (
					select BB.PID 
					 from [SAESA2005]..BORDER_ENTRY_NEW BB
					where BB.DELETE_DATE IS NULL AND BB.DOC_TYPE = 3 AND DATEADD(day, 1, BB.OUT_DATE) >= J.P_PRISIONER_MarktDate
					)

	exec SP_ADD_LOG N'[JUST]', N'JUST DEADS'				-- გარდაცვალება
	update [LIVE_SCORES_F] set PERSON_STATE = 200 
	from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_JUST_SDB J on J.PID=A.PID collate Latin1_General_BIN  
	where J.P_DEATH_STATUS in (1, 2)
					AND A.PID not in (
					select BB.PID 
					from [SAESA2005]..BORDER_ENTRY_NEW BB
					where BB.DELETE_DATE IS NULL AND BB.DOC_TYPE = 2 AND DATEADD(day, 1, BB.OUT_DATE) >= J.P_DEATH_DATE
					)

	exec SP_ADD_LOG N'[JUST]', N'FINISH JUST'

    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP FINISH LIVESCORES!!!'

    insert into HISTORY_LOG values (CURRENT_TIMESTAMP)


    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'START FILL_FROM_SASEA2005_PART_2'

    exec SAESA2005.dbo.FILL_FROM_SASEA2005_PART_2

  /*
  exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'[DECLARATION_FAMILY_QUEST_V1V2_ARC]'

  -------------------------------------------------------- [DECLARATION_FAMILY_QUEST_V2_ARC]
  INSERT INTO [dbo].[DECLARATION_FAMILY_QUEST_V1V2_ARC]
           ([FID]
           ,[DID]
           ,[ITEM_NO]
           ,[QTYPE]
           ,[QID]
           ,[QVALUE_TYPE]
           ,[QVALUE_BIT]
           ,[QVALUE_INT]
           ,[QVALUE_MONEY]
           ,[QVALUE_TEXT])
  SELECT DISTINCT [FID]
      ,[DID]
      ,[ITEM_NO]
      ,T.[QTYPE_V2] as [QTYPE]
      ,T.[QID_V2] as [QID]
      ,[QVALUE_TYPE]
      ,[QVALUE_BIT]
      ,[QVALUE_INT]
      ,[QVALUE_MONEY]
      ,[QVALUE_TEXT]
  FROM [dbo].[WORK_DECLARATION_FAMILY_QUEST_V2_ARC] Q
    inner join dbo.DECLARATION_FAMILY_QUEST_ARC_TRANSFORMATION T
    on Q.QTYPE=T.QTYPE_V2 and Q.QID =T.QID_V2

  -------------------------------------------------------- [DECLARATION_FAMILY_QUEST_ARC]
  exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'[DECLARATION_FAMILY_QUEST_V1V2_ARC]'

  INSERT INTO [dbo].[DECLARATION_FAMILY_QUEST_V1V2_ARC]
           ([FID]
           ,[DID]
           ,[ITEM_NO]
           ,[QTYPE]
           ,[QID]
           ,[QVALUE_TYPE]
           ,[QVALUE_BIT]
           ,[QVALUE_INT]
           ,[QVALUE_MONEY]
           ,[QVALUE_TEXT])
  SELECT [FID]
      ,[DID]
      ,[ITEM_NO]
      ,T.[QTYPE_V2] as [QTYPE]
      ,T.[QID_V2] as [QID]
      ,MIN([QVALUE_TYPE])
      ,[QVALUE_BIT]
      ,MIN([QVALUE_INT])
      ,SUM([QVALUE_MONEY])
      ,MIN([QVALUE_TEXT])
  FROM [dbo].[WORK_DECLARATION_FAMILY_QUEST_ARC] Q
    inner join dbo.DECLARATION_FAMILY_QUEST_ARC_TRANSFORMATION T
    on Q.QTYPE=T.QTYPE_V1 and Q.QID=T.QID_V1
  group by [FID]
      ,[DID]
      ,[ITEM_NO]
      ,T.[QTYPE_V2]
      ,T.[QID_V2]
      ,[QVALUE_BIT] 
      
*/

/*
------------------------------------------------------[DECLARATION_QUEST_V2_ARC]
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'[DECLARATION_QUEST_V1V2_ARC]'

  INSERT INTO [dbo].[DECLARATION_QUEST_V1V2_ARC]
           ([FID]
           ,[REC_ID]
           ,[QTYPE]
           ,[QID]
           ,[QVALUE_TYPE]
           ,[QVALUE_BIT]
           ,[QVALUE_INT]
           ,[QVALUE_MONEY]
           ,[QVALUE_TEXT])
  
  SELECT DISTINCT [FID]
      ,[REC_ID]
      ,T.[QTYPE_V2_TRANS]  as [QTYPE]
      ,T.[QID_V2_TRANS]  as [QID]
      ,[QVALUE_TYPE]
      ,[QVALUE_BIT]
      ,[QVALUE_INT]
      ,[QVALUE_MONEY]
      ,[QVALUE_TEXT]
  FROM [dbo].[WORK_DECLARATION_QUEST_V2_ARC] Q
  inner join dbo.DECLARATION_QUEST_ARC_TRANSFORMATION T
    on Q.QTYPE=T.QTYPE_V2 and Q.QID=T.QID_V2 
  


------------------------------------------------------[DECLARATION_QUEST_ARC]
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'[DECLARATION_QUEST_V1V2_ARC]'

  INSERT INTO [dbo].[DECLARATION_QUEST_V1V2_ARC]
           ([FID]
           ,[REC_ID]
           ,[QTYPE]
           ,[QID]
           ,[QVALUE_TYPE]
           ,[QVALUE_BIT]
           ,[QVALUE_INT]
           ,[QVALUE_MONEY]
           ,[QVALUE_TEXT])
  
  SELECT [FID]
      ,[REC_ID]
      ,T.[QTYPE_V2_TRANS]  as [QTYPE]
      ,T.[QID_V2_TRANS]  as [QID]
      ,MIN([QVALUE_TYPE])
      ,[QVALUE_BIT]
      ,MIN([QVALUE_INT])
      ,SUM([QVALUE_MONEY])
      ,MIN([QVALUE_TEXT])
  FROM [dbo].[WORK_DECLARATION_QUEST_ARC] Q
  inner join dbo.DECLARATION_QUEST_ARC_TRANSFORMATION T
    on Q.QTYPE=T.QTYPE_V1 and Q.QID=T.QID_V1 
   group by [FID]
      ,[REC_ID]
      ,T.[QTYPE_V2_TRANS]
      ,T.[QID_V2_TRANS]
      ,[QVALUE_BIT]
 
 */
  
/* ************  JUST
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'JUST  DEADS'

--JUST  DEADS
  update [LIVE_SCORES_F] set PERSON_STATE = 200 from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_DEADS J on J.PID=A.PID collate Latin1_General_BIN  // aq me mgoni 1, 2 unda  -- zura

    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'JUST PRISIONERS'
 
--JUST  DEADS
  update [LIVE_SCORES_F] set PERSON_STATE = 999 from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_PRISIONERS J on J.PID=A.PID collate Latin1_General_BIN

    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'JUST OTHER'

--JUST #1 
  update [LIVE_SCORES_F] set CONDITION_ID=J.CONDITION_ID, STATUS_ID=J.STATUS_ID from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_JUST J 
        on (A.CONDITION_ID is null) --(A.IDENT is null)
          and J.PID=A.PID collate Latin1_General_BIN
          and (LEFT(J.FIRST, 3)= dbo.fn_conutf82alta(LEFT(A.FIRST_NAME, 3)) collate Latin1_General_BIN)
          and (LEFT(J.LAST, 4)= dbo.fn_conutf82alta(LEFT(A.LAST_NAME, 4)) collate Latin1_General_BIN)
		  and (J.BIRTH_DATE = A.BIRTH_DATE)		  

--JUST #2 
  update [LIVE_SCORES_F] set  CONDITION_ID=J.CONDITION_ID, STATUS_ID=J.STATUS_ID from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_JUST J 
        on (A.CONDITION_ID is null) --(A.IDENT is null)
          and (J.PID=A.PID collate Latin1_General_BIN)
          and (LEFT(J.FIRST, 3)= dbo.fn_conutf82alta(LEFT(A.FIRST_NAME, 3)) collate Latin1_General_BIN)

--JUST #3 
  update [LIVE_SCORES_F] set  CONDITION_ID=J.CONDITION_ID, STATUS_ID=J.STATUS_ID from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_JUST J 
        on (A.CONDITION_ID is null) --(A.IDENT is null)
          and (J.PID=A.PID collate Latin1_General_BIN)
          and (LEFT(J.LAST, 4)= dbo.fn_conutf82alta(LEFT(A.LAST_NAME, 4)) collate Latin1_General_BIN)

--JUST #4 
  update [LIVE_SCORES_F] set  CONDITION_ID=J.CONDITION_ID, STATUS_ID=J.STATUS_ID from [LIVE_SCORES_F] A
    inner join [JUST].dbo.VW_JUST J 
        on (A.CONDITION_ID is null) --(A.IDENT is null)
          and (J.PID=A.PID collate Latin1_General_BIN)
		  and (J.BIRTH_DATE = A.BIRTH_DATE)
*/
------


/*
-----------------------------[DECLARATION_FAMILY_V1V2_ARC]
  exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'DECLARATION_FAMILY_V1V2_ARC'

INSERT INTO [FAMILY_DATA].[dbo].[DECLARATION_FAMILY_V1V2_ARC]
           ([FID]
           ,[SOURCE]
           ,[DID]
           ,[ITEM_NO]
           ,[FIRST_NAME]
           ,[LAST_NAME]
           ,[SEX]
           ,[BIRTH_DATE]
           ,[AGE]
           ,[PID]
           ,[ACTION_DATE]
           ,[ACTION_TYPE]
           ,[PERSON_STATE]
           ,[STATUS_ID]  
           ,[CONDITION_ID] 
           ,[IDENT] 
           ,[SRA_ID])
SELECT [FID]
      ,[SOURCE]
      ,[REC_ID] as [DID]
      ,[ITEM_NO]
      ,[FIRST_NAME]
      ,[LAST_NAME]
      ,[SEX]
      ,[BIRTH_DATE]
      ,[AGE]
      ,[PID]
      ,[ACTION_DATE]
      ,[ACTION_CODE] as [ACTION_TYPE] 
      ,[PERSON_STATE] 
      ,[STATUS_ID]  
      ,[CONDITION_ID] 
      ,[IDENT] 
      ,[SRA_ID]
  FROM [dbo].[LIVE_SCORES_F] 
  */
----------------------------------------------------------[DECLARATIONS_V1V2_ARC]
/*
    exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'[DECLARATIONS_V1V2_ARC]'

INSERT INTO [dbo].[DECLARATIONS_V1V2_ARC]
           ([SOURCE]
           ,[REC_ID]
           ,[ROW_VERSION]
           ,[REC_STATE]
           ,[REC_DATE]
           ,[PARENT_REC_ID]
           ,[REC_VERSION]
           ,[TRUE_VER_REC_ID]
           ,[WITH_ERROR]
           ,[OWNER]
           ,[REGION_ID]
           ,[SACODE]
           ,[FID]
           ,[ZIP_CODE]
           ,[CITY]
           ,[REGION]
           ,[GOVERNMENT]
           ,[VILLAGE]
           ,[ADDRESS]
           ,[ADDRESS_NO]
           ,[HOME_1]
           ,[HOME_2]
           ,[HOME_PHONE]
           ,[HOME_PHONE_ALT]
           ,[HOME_PHONE_ALT_DESCRIP]
           ,[MOB_PHONE_1]
           ,[MOB_PHONE_2]
           ,[FO_FIRST_NAME]
           ,[FO_LAST_NAME]
           ,[FO_PID]
           ,[VISIT_DATE]
           ,[ORDER_DATE]
)
SELECT DISTINCT
       L.[SOURCE]
      ,L.[REC_ID]
      ,[ROW_VERSION]
      ,[REC_STATE]
      ,[REC_DATE]
      ,[PARENT_REC_ID]
      ,[REC_VERSION]
      ,[TRUE_VER_REC_ID]
      ,[WITH_ERROR]
      ,[OWNER]
      ,L.[REGION_ID]
      ,[SACODE]
      ,L.[FID]
      ,L.[ZIP_CODE]
      ,L.[CITY]
      ,L.[REGION]
      ,L.[GOVERNMENT]
      ,L.[VILLAGE]
      ,[ADDRESS]
      ,[ADDRESS_NO]
      ,[HOME_1]
      ,[HOME_2]
      ,[HOME_PHONE]
      ,[HOME_PHONE_ALT]
      ,[HOME_PHONE_ALT_DESCRIP]
      ,'(' + [MOB_INDEX] + ') ' + [MOB_PHONE]
      ,NULL
      ,[FO_FIRST_NAME]
      ,[FO_LAST_NAME]
      ,[FO_PID]
      ,L.[VISIT_DATE]
      ,[ORDER_DATE]

  FROM [dbo].[LIVE_SCORES_F] L
     inner join /*[172.17.250.10].*/[SAESA2005].[dbo].DECLARATIONS_V2_ARC D 
       on D.FID=L.FID 
       and D.REC_ID=L.REC_ID
       and D.REC_VERSION=3
       and L.SOURCE=2   



INSERT INTO [dbo].[DECLARATIONS_V1V2_ARC]
           ([SOURCE]
           ,[REC_ID]
           ,[ROW_VERSION]
           ,[REC_STATE]
           ,[REC_DATE]
           ,[PARENT_REC_ID]
           ,[REC_VERSION]
           ,[TRUE_VER_REC_ID]
           ,[WITH_ERROR]
           ,[OWNER]
           ,[REGION_ID]
           ,[SACODE]
           ,[FID]
           ,[ZIP_CODE]
           ,[CITY]
           ,[REGION]
           ,[GOVERNMENT]
           ,[VILLAGE]
           ,[ADDRESS]
           ,[ADDRESS_NO]
           ,[HOME_1]
           ,[HOME_2]
           ,[HOME_PHONE]
           ,[HOME_PHONE_ALT]
           ,[HOME_PHONE_ALT_DESCRIP]
           ,[MOB_PHONE_1]
           ,[MOB_PHONE_2]
           ,[FO_FIRST_NAME]
           ,[FO_LAST_NAME]
           ,[FO_PID]
           ,[VISIT_DATE]
           ,[ORDER_DATE]
)
SELECT DISTINCT
       L.[SOURCE]
      ,L.[REC_ID]
      ,NULL
      ,[REC_STATE]
      ,[REC_DATE]
      ,[PARENT_REC_ID]
      ,[REC_VERSION]
      ,[TRUE_VER_REC_ID]
      ,[WITH_ERROR]
      ,[OWNER]
      ,L.[REGION_ID]
      ,[SACODE]
      ,L.[FID]
      ,L.[ZIP_CODE]
      ,L.[CITY]
      ,L.[REGION]
      ,L.[GOVERNMENT]
      ,L.[VILLAGE]
      ,[ADDRESS]
      ,[ADDRESS_NO]
      ,[HOME_1]
      ,[HOME_2]
      ,[HOME_PHONE]
      ,[HOME_PHONE_ALT]
      ,[HOME_PHONE_ALT_DESCRIP]
      ,[MOB_PHONE_1]
      ,[MOB_PHONE_2]
      ,[FO_FIRST_NAME]
      ,[FO_LAST_NAME]
      ,[FO_PASS_NO]
      ,L.[VISIT_DATE]
      ,NULL

  FROM [dbo].[LIVE_SCORES_F] L
     inner join /*[172.17.250.10].*/[SAESA2005].[dbo].DECLARATIONS_ARC D 
       on D.FID=L.FID 
       and D.REC_ID=L.REC_ID
       and D.REC_VERSION=3
       and L.SOURCE=1   



INSERT INTO [dbo].[DECLARATIONS_V1V2_ARC]
           ([SOURCE]
           ,[REC_ID]
           ,[ROW_VERSION]
           ,[REC_STATE]
           ,[REC_DATE]
           ,[PARENT_REC_ID]
           ,[REC_VERSION]
           ,[TRUE_VER_REC_ID]
           ,[WITH_ERROR]
           ,[OWNER]
           ,[REGION_ID]
           ,[SACODE]
           ,[FID]
           ,[ZIP_CODE]
           ,[CITY]
           ,[REGION]
           ,[GOVERNMENT]
           ,[VILLAGE]
           ,[ADDRESS]
           ,[ADDRESS_NO]
           ,[HOME_1]
           ,[HOME_2]
           ,[HOME_PHONE]
           ,[HOME_PHONE_ALT]
           ,[HOME_PHONE_ALT_DESCRIP]
           ,[MOB_PHONE_1]
           ,[MOB_PHONE_2]
           ,[FO_FIRST_NAME]
           ,[FO_LAST_NAME]
           ,[FO_PID]
           ,[VISIT_DATE]
           ,[ORDER_DATE]
)
SELECT DISTINCT
       L.[SOURCE]
      ,L.[REC_ID]
      ,[ROW_VERSION]
      ,[REC_STATE]
      ,[REC_DATE]
      ,[PARENT_REC_ID]
      ,[REC_VERSION]
      ,[TRUE_VER_REC_ID]
      ,[WITH_ERROR]
      ,[OWNER]
      ,L.[REGION_ID]
      ,[SACODE]
      ,L.[FID]
      ,L.[ZIP_CODE]
      ,L.[CITY]
      ,L.[REGION]
      ,L.[GOVERNMENT]
      ,L.[VILLAGE]
      ,[ADDRESS]
      ,[ADDRESS_NO]
      ,[HOME_1]
      ,[HOME_2]
      ,[HOME_PHONE]
      ,[HOME_PHONE_ALT]
      ,[HOME_PHONE_ALT_DESCRIP]
      ,'(' + [MOB_INDEX] + ') ' + [MOB_PHONE]
      ,NULL
      ,[FO_FIRST_NAME]
      ,[FO_LAST_NAME]
      ,[FO_PID]
      ,L.[VISIT_DATE]
      ,[ORDER_DATE]

  FROM [dbo].[LIVE_SCORES_F] L
     inner join /*[172.17.250.10].*/[SAESA2005].[dbo].DECLARATIONS_V2_HISTORY D 
       on D.FID=L.FID 
       and D.REC_ID=L.REC_ID
       and D.REC_VERSION=3
       and L.SOURCE=4   



INSERT INTO [dbo].[DECLARATIONS_V1V2_ARC]
           ([SOURCE]
           ,[REC_ID]
           ,[ROW_VERSION]
           ,[REC_STATE]
           ,[REC_DATE]
           ,[PARENT_REC_ID]
           ,[REC_VERSION]
           ,[TRUE_VER_REC_ID]
           ,[WITH_ERROR]
           ,[OWNER]
           ,[REGION_ID]
           ,[SACODE]
           ,[FID]
           ,[ZIP_CODE]
           ,[CITY]
           ,[REGION]
           ,[GOVERNMENT]
           ,[VILLAGE]
           ,[ADDRESS]
           ,[ADDRESS_NO]
           ,[HOME_1]
           ,[HOME_2]
           ,[HOME_PHONE]
           ,[HOME_PHONE_ALT]
           ,[HOME_PHONE_ALT_DESCRIP]
           ,[MOB_PHONE_1]
           ,[MOB_PHONE_2]
           ,[FO_FIRST_NAME]
           ,[FO_LAST_NAME]
           ,[FO_PID]
           ,[VISIT_DATE]
           ,[ORDER_DATE]
)
SELECT DISTINCT
       L.[SOURCE]
      ,L.[REC_ID]
      ,NULL
      ,30
      ,[REC_DATE]
      ,[PARENT_REC_ID]
      ,[REC_VERSION]
      ,[TRUE_VER_REC_ID]
      ,0
      ,[OWNER]
      ,L.[REGION_ID]
      ,[SACODE]
      ,L.[FID]
      ,L.[ZIP_CODE]
      ,L.[CITY]
      ,L.[REGION]
      ,L.[GOVERNMENT]
      ,L.[VILLAGE]
      ,[ADDRESS]
      ,[ADDRESS_NO]
      ,[HOME_1]
      ,[HOME_2]
      ,[HOME_PHONE]
      ,[HOME_PHONE_ALT]
      ,[HOME_PHONE_ALT_DESCRIP]
      ,[MOB_PHONE_1]
      ,[MOB_PHONE_2]
      ,[FO_FIRST_NAME]
      ,[FO_LAST_NAME]
      ,[FO_PASS_NO]
      ,L.[VISIT_DATE]
      ,NULL

  FROM [dbo].[LIVE_SCORES_F] L
     inner join /*[172.17.250.10].*/[SAESA2005].[dbo].DECLARATIONS_HISTORY D 
       on D.FID=L.FID 
       and D.REC_ID=L.REC_ID
       and D.REC_VERSION=3
       and L.SOURCE=3   
	   */

/*
---------------------------family_data
    INSERT INTO [FAMILY_DATA].[dbo].[FAMILY_DATA]
           ([FID]
           ,[STATE]
           ,[CALC_DATE]
           ,[ADT]
           ,[REGION_ID]
           ,[SACODE]
           ,[ZIP_CODE]
           ,[CITY]
           ,[REGION]
           ,[GOVERNMENT]
           ,[VILLAGE]
           ,[ADDRESS]
           ,[ADDRESS_NO]
           ,[HOME_1]
           ,[HOME_2]
           ,[FULL_ADDRESS]
           ,[HOME_PHONE]
           ,[MOB_PHONE]
           ,[FO_LAST_NAME]
           ,[FO_FIRST_NAME]
           ,[FO_PASS_NO]
           ,[MEMBERS_COUNT]
           ,[FAMILY_SCORE]
           ,[CURRENT_DISB_MONEY]
           ,[ACCRUAL_MONTH]
           ,[PREPARE_DISB_MONTH]
           ,[ON_CONTROL]
           ,[SCORE_OLD]
           ,[SCORE_NEW]
           ,[VISIT_DATE]
           ,[FAMILY_SCORE_V2]
           ,[LEGAL_SCORE_DATE]
           ,[LEGAL_FAMILY_SCORE]
           ,[ACTIVE_VISIT_DATE]
           ,[DOC_DATE]
           ,[SCORE_BEFORE_RECALC]
           ,[OQMI_DATE]
           ,[SCORE_BEFORE_OQMI])
     select 
			FS.[FID]
           ,FS.[STATE]
           ,FS.[CALC_DATE]
           ,FS.[ADT]
           ,FS.[REGION_ID]
           ,FS.[SACODE]
           ,FS.[ZIP_CODE]
           ,FS.[CITY]
           ,FS.[REGION]
           ,FS.[GOVERNMENT]
           ,FS.[VILLAGE]
           ,FS.[ADDRESS]
           ,FS.[ADDRESS_NO]
           ,FS.[HOME_1]
           ,FS.[HOME_2]
           ,FS.[FULL_ADDRESS]
           ,FS.[HOME_PHONE]
           ,FS.[MOB_PHONE]
           ,FS.[FO_LAST_NAME]
           ,FS.[FO_FIRST_NAME]
           ,FS.[FO_PASS_NO]
           ,FS.[MEMBERS_COUNT]
           ,FS.[FAMILY_SCORE]
           ,FS.[CURRENT_DISB_MONEY]
           ,FS.[ACCRUAL_MONTH]
           ,FS.[PREPARE_DISB_MONTH]
           ,FS.[ON_CONTROL]
           ,FS.[SCORE_OLD]
           ,FS.[SCORE_NEW]
           ,FS.[VISIT_DATE]
           ,FS.[FAMILY_SCORE_V2]
           ,FS.[LEGAL_SCORE_DATE]
           ,FS.[LEGAL_FAMILY_SCORE]
           ,FS.[ACTIVE_VISIT_DATE]
           ,FS.[DOC_DATE]
           ,FS.[SCORE_BEFORE_RECALC]
           ,FS.[OQMI_DATE]
           ,FS.[SCORE_BEFORE_OQMI]
	from /*[172.17.250.10].*/[SAESA2005].[dbo].[FAMILY_DATA] FS
	inner join DECLARATIONS_V1V2_ARC D on D.FID=FS.FID and D.SOURCE in (1, 2)

---------------------------family_data history v1
    INSERT INTO [FAMILY_DATA].[dbo].[FAMILY_DATA]
           ([FID]
           ,[STATE]
           ,[CALC_DATE]
           ,[ADT]
           ,[REGION_ID]
           ,[SACODE]
           ,[ZIP_CODE]
           ,[CITY]
           ,[REGION]
           ,[GOVERNMENT]
           ,[VILLAGE]
           ,[ADDRESS]
           ,[ADDRESS_NO]
           ,[HOME_1]
           ,[HOME_2]
           ,[FULL_ADDRESS]
           ,[HOME_PHONE]
           ,[MOB_PHONE]
           ,[FO_LAST_NAME]
           ,[FO_FIRST_NAME]
           ,[FO_PASS_NO]
           ,[MEMBERS_COUNT]
           ,[FAMILY_SCORE]
           ,[CURRENT_DISB_MONEY]
           ,[ACCRUAL_MONTH]
           ,[PREPARE_DISB_MONTH]
           ,[ON_CONTROL]
           ,[SCORE_OLD]
           ,[SCORE_NEW]
           ,[VISIT_DATE]
           ,[FAMILY_SCORE_V2]
           ,[LEGAL_SCORE_DATE]
           ,[LEGAL_FAMILY_SCORE]
           ,[ACTIVE_VISIT_DATE]
           ,[DOC_DATE]
           ,[SCORE_BEFORE_RECALC]
           ,[OQMI_DATE]
           ,[SCORE_BEFORE_OQMI])
    select 
			FS.[FID]
           ,FS.[STATE]
           ,FS.[CALC_DATE]
           ,FS.[ADT]
           ,FS.[REGION_ID]
           ,FS.[SACODE]
           ,FS.[ZIP_CODE]
           ,FS.[CITY]
           ,FS.[REGION]
           ,FS.[GOVERNMENT]
           ,FS.[VILLAGE]
           ,FS.[ADDRESS]
           ,FS.[ADDRESS_NO]
           ,FS.[HOME_1]
           ,FS.[HOME_2]
           ,FS.[FULL_ADDRESS]
           ,FS.[HOME_PHONE]
           ,FS.[MOB_PHONE]
           ,FS.[FO_LAST_NAME]
           ,FS.[FO_FIRST_NAME]
           ,FS.[FO_PASS_NO]
           ,FS.[MEMBERS_COUNT]
           ,FS.[FAMILY_SCORE]
           ,FS.[CURRENT_DISB_MONEY]
           ,FS.[ACCRUAL_MONTH]
           ,FS.[PREPARE_DISB_MONTH]
           ,FS.[ON_CONTROL]
           ,FS.[SCORE_OLD]
           ,FS.[SCORE_NEW]
           ,FS.[VISIT_DATE]
           ,FS.[FAMILY_SCORE_V2]
           ,FS.[LEGAL_SCORE_DATE]
           ,FS.[FAMILY_SCORE]
           ,FS.[VISIT_DATE]
           ,FS.[DOC_DATE]
           ,FS.[SCORE_BEFORE_RECALC]
           ,FS.[OQMI_DATE]
           ,FS.[SCORE_BEFORE_OQMI]
	from /*[172.17.250.10].*/[SAESA2005].[dbo].[FAMILY_DATA_HISTORY] FS
	inner join DECLARATIONS_V1V2_ARC D on D.FID=FS.FID
	inner join /*[172.17.250.10].*/[SAESA2005].[dbo].DECLARATIONS_HISTORY DH on DH.FID=FS.FID and DH.REC_ID=D.REC_ID and FS.FID_VERSION=DH.FID_VERSION


---------------------------family_data history v2
     INSERT INTO [FAMILY_DATA].[dbo].[FAMILY_DATA]
           ([FID]
           ,[STATE]
           ,[CALC_DATE]
           ,[ADT]
           ,[REGION_ID]
           ,[SACODE]
           ,[ZIP_CODE]
           ,[CITY]
           ,[REGION]
           ,[GOVERNMENT]
           ,[VILLAGE]
           ,[ADDRESS]
           ,[ADDRESS_NO]
           ,[HOME_1]
           ,[HOME_2]
           ,[FULL_ADDRESS]
           ,[HOME_PHONE]
           ,[MOB_PHONE]
           ,[FO_LAST_NAME]
           ,[FO_FIRST_NAME]
           ,[FO_PASS_NO]
           ,[MEMBERS_COUNT]
           ,[FAMILY_SCORE]
           ,[CURRENT_DISB_MONEY]
           ,[ACCRUAL_MONTH]
           ,[PREPARE_DISB_MONTH]
           ,[ON_CONTROL]
           ,[SCORE_OLD]
           ,[SCORE_NEW]
           ,[VISIT_DATE]
           ,[FAMILY_SCORE_V2]
           ,[LEGAL_SCORE_DATE]
           ,[LEGAL_FAMILY_SCORE] 
           ,[ACTIVE_VISIT_DATE] 
           ,[DOC_DATE]
           ,[SCORE_BEFORE_RECALC]
           ,[OQMI_DATE]
           ,[SCORE_BEFORE_OQMI])
    select 
			FS.[FID]
           ,FS.[STATE]
           ,FS.[CALC_DATE]
           ,FS.[ADT]
           ,FS.[REGION_ID]
           ,FS.[SACODE]
           ,FS.[ZIP_CODE]
           ,FS.[CITY]
           ,FS.[REGION]
           ,FS.[GOVERNMENT]
           ,FS.[VILLAGE]
           ,FS.[ADDRESS]
           ,FS.[ADDRESS_NO]
           ,FS.[HOME_1]
           ,FS.[HOME_2]
           ,FS.[FULL_ADDRESS]
           ,FS.[HOME_PHONE]
           ,FS.[MOB_PHONE]
           ,FS.[FO_LAST_NAME]
           ,FS.[FO_FIRST_NAME]
           ,FS.[FO_PASS_NO]
           ,FS.[MEMBERS_COUNT]
           ,FS.[FAMILY_SCORE]
           ,FS.[CURRENT_DISB_MONEY]
           ,FS.[ACCRUAL_MONTH]
           ,FS.[PREPARE_DISB_MONTH]
           ,FS.[ON_CONTROL]
           ,FS.[SCORE_OLD]
           ,FS.[SCORE_NEW]
           ,FS.[VISIT_DATE]
           ,FS.[FAMILY_SCORE_V2]
           ,FS.[LEGAL_SCORE_DATE]
           ,FS.[FAMILY_SCORE]
           ,FS.[VISIT_DATE]
           ,FS.[DOC_DATE]
           ,FS.[SCORE_BEFORE_RECALC]
           ,FS.[OQMI_DATE]
           ,FS.[SCORE_BEFORE_OQMI]
	from /*[172.17.250.10].*/[SAESA2005].[dbo].[FAMILY_DATA_HISTORY] FS
	inner join DECLARATIONS_V1V2_ARC D on D.FID=FS.FID
	inner join /*[172.17.250.10].*/[SAESA2005].[dbo].DECLARATIONS_V2_HISTORY DH on DH.FID=FS.FID and DH.REC_ID=D.REC_ID and FS.FID_VERSION=DH.FID_VERSION

*/

	
    if DAY(CURRENT_TIMESTAMP) = 1 begin
      exec SP_ADD_LOG N'[FILL_LIVE_SCORES_2]', N'STEP BACKUP LIVESCORES for 1 day!!!'
      DECLARE @QR VARCHAR(250)
      SET @QR = 'SELECT * INTO dbo.LIVE_SCORES_' + CONVERT(VARCHAR(4), YEAR(CURRENT_TIMESTAMP)) + RIGHT('00' + LTRIM(CONVERT(VARCHAR(2), MONTH(CURRENT_TIMESTAMP))),2) +  '01' +' from dbo.LIVE_SCORES_F'
      EXEC(@QR)
    END

	exec SP_ADD_LOG N'[FILL_LIVE_SCORES_3]', N'FINISH_ALL'

	insert into HISTORY_LOG values (CURRENT_TIMESTAMP)

END
GO
/****** Object:  StoredProcedure [dbo].[FILL_LIVE_SCORES_OLD_FROM_TEMP]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[FILL_LIVE_SCORES_OLD_FROM_TEMP] 

@op_date smalldatetime

AS
BEGIN

	SET NOCOUNT ON;
	
	print 0
    print @op_date 
    
    exec saesa_temp.dbo.FILL_FROM_saesa_temp


	DECLARE @TA TABLE (FID TFID, FID_VERSION INT, SOURCE INT, REC_ID INT, RESORE_DOC_NO VARCHAR(50), RESTORE_DOC_DATE SMALLDATETIME)

	delete [dbo].[LIVE_SCORES_OLD]

		
	print 1
    print @op_date 

	INSERT INTO [dbo].[LIVE_SCORES_OLD]
			   ([FID]
			   ,[SOURCE]
			   ,[REC_ID] 
			   ,[ITEM_NO]
			   ,[FAMILY_SCORE]
			   ,[REGION_ID]
			   ,[REGION] 
			   ,[ZIP_CODE]
			   ,[CITY]
			   ,[GOVERNMENT]
			   ,[VILLAGE]
			   ,[FULL_ADDRESS]
			   ,[PID]
			   ,[BIRTH_DATE]
			   ,[FIRST_NAME]
			   ,[LAST_NAME]
			   ,[AGE] 
			   ,[SEX] 
			   ,[ACTION_CODE]
			   ,[ACTION_DATE]
			   ,[SCORE_DATE]
			   ,[VISIT_DATE]
			   ,[RESORE_DOC_NO]
			   ,[RESTORE_DOC_DATE]
			   ,[IDENT] 
			   ,[SRA_ID])
	  select F.FID,
	     1,  
	     D.REC_ID,
	     P.ITEM_NO,
		 F.LEGAL_FAMILY_SCORE, 
		 F.REGION_ID, 
		 dbo.fn_con2utf8(F.REGION), 
		 F.ZIP_CODE, 
		 dbo.fn_con2utf8(F.CITY), 
		 dbo.fn_con2utf8(F.GOVERNMENT), 
		 dbo.fn_con2utf8(F.VILLAGE), 
		 dbo.fn_con2utf8(F.FULL_ADDRESS), 
		 P.PASS_ID as PID, 
		 P.BIRTH_DATE, 
		 dbo.fn_con2utf8(P.FIRST_NAME), 
		 dbo.fn_con2utf8(P.LAST_NAME), 
		 0, --P.AGE,
		 P.SEX,
		 P.ACTION_TYPE,
		 P.ACTION_DATE,
		 F.LEGAL_SCORE_DATE, 
		 F.VISIT_DATE,
		 F.RESORE_DOC_NO,
		 F.RESTORE_DOC_DATE, 
		 P.PIROBA,
		 P.J_ID
	  from /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA F
		inner join /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA_PERSONS P 
		    on F.FID=P.FID
		inner join /*[172.17.250.10].*/[saesa_temp].[dbo].DECLARATIONS_ARC D 
		    on D.FID=F.FID 
		      and D.REC_VERSION=3
		where (ON_CONTROL=0) 
		  --and  ((LEGAL_SCORE_DATE <= @op_date) or (F.OQMI_DATE is not null) or (F.DOC_DATE is not null)) 
		  --and (F.LEGAL_FAMILY_SCORE <70001)
		  --and (P.ACTION_TYPE is null or P.ACTION_TYPE='100') 
	
	
	print 2 
    print @op_date 
	INSERT INTO [dbo].[LIVE_SCORES_OLD]
			   ([FID]
			   ,[SOURCE] 
			   ,[REC_ID] 
			   ,[ITEM_NO]
			   ,[FAMILY_SCORE]
			   ,[REGION_ID]
			   ,[REGION] 
			   ,[ZIP_CODE]
			   ,[CITY]
			   ,[GOVERNMENT]
			   ,[VILLAGE]
			   ,[FULL_ADDRESS]
			   ,[PID]
			   ,[BIRTH_DATE]
			   ,[FIRST_NAME]
			   ,[LAST_NAME]
			   ,[AGE] 
			   ,[SEX] 
			   ,[ACTION_CODE]
			   ,[ACTION_DATE]
			   ,[SCORE_DATE]
			   ,[VISIT_DATE]
			   ,[RESORE_DOC_NO]
			   ,[RESTORE_DOC_DATE]
			   ,[IDENT] 
			   ,[SRA_ID])
	  select F.FID, 
	     2,
	     D.REC_ID,
	     P.ITEM_NO,
		 F.LEGAL_FAMILY_SCORE, 
		 F.REGION_ID, 
		 dbo.fn_con2utf8(F.REGION), 
		 F.ZIP_CODE, 
		 dbo.fn_con2utf8(F.CITY), 
		 dbo.fn_con2utf8(F.GOVERNMENT), 
		 dbo.fn_con2utf8(F.VILLAGE), 
		 dbo.fn_con2utf8(F.FULL_ADDRESS), 
		 P.PASS_ID as PID, 
		 P.BIRTH_DATE, 
		 dbo.fn_con2utf8(P.FIRST_NAME), 
		 dbo.fn_con2utf8(P.LAST_NAME), 
		 0,--P.AGE,
		 P.SEX,
		 P.ACTION_TYPE,
		 P.ACTION_DATE,
		 CASE WHEN /*(F.OQMI_DATE is NULL) and*/ (F.LEGAL_SCORE_DATE < @op_date) 
		    THEN F.LEGAL_SCORE_DATE 
		    ELSE DATEADD(D, 30, F.VISIT_DATE) 
		       /*CASE WHEN (F.OQMI_DATE NOT NULL) 
		          THEN DATEADD(D, 30, F.VISIT_DATE) 
		          ELSE DATEADD(D, 30, F.VISIT_DATE) */
		          
		 END as LEGAL_SCORE_DATE,  
		 F.VISIT_DATE,
		 F.RESORE_DOC_NO,
		 F.RESTORE_DOC_DATE, 
		 P.PIROBA,
		 P.J_ID 
	  from /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA F
		inner join /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA_PERSONS P 
		   on F.FID=P.FID
		inner join /*[172.17.250.10].*/[saesa_temp].[dbo].DECLARATIONS_V2_ARC D 
		   on D.FID=F.FID 
		     and D.REC_VERSION=3
		where (ON_CONTROL=0) 
		  and  ((LEGAL_SCORE_DATE <= @op_date) 
		        or (F.OQMI_DATE is not null) 
		        or ((F.DOC_DATE is not null) and (DATEADD(D, 30, F.VISIT_DATE) < @op_date))) 
		  --and (F.LEGAL_FAMILY_SCORE <70001)
		  --and (P.ACTION_TYPE is null or P.ACTION_TYPE='100') 	 
    
    print 3
    print @op_date 	
	INSERT INTO @TA (FID, FID_VERSION, SOURCE, REC_ID, RESORE_DOC_NO, RESTORE_DOC_DATE)
	  select D.FID, D.FID_VERSION, 3, D.REC_ID, FD.RESORE_DOC_NO, FD.RESTORE_DOC_DATE
	   from /*[172.17.250.10].*/[saesa_temp].[dbo].DECLARATIONS_HISTORY D 
		inner join /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA_HISTORY FD 
		   on D.FID=FD.FID 
		     and FD.FID_VERSION=D.FID_VERSION
		left outer join /*[172.17.250.10].*/[saesa_temp].[dbo].FORM_3 F3 
		   on F3.FID=D.FID
		LEFT outer join [dbo].[LIVE_SCORES_OLD] AC 
		   on AC.FID=D.FID
		where ((D.ADD_DATE > @op_date - 26) or EXISTS(SELECT NULL FROM /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA R WHERE (R.FID=D.FID) and ((LEGAL_SCORE_DATE > @op_date) or (R.ON_CONTROL = 1))))
		  and (D.REC_VERSION=3) 
		  and (FD.ON_CONTROL=0)
		  and (F3.FID is NULL)
		  and (AC.FID is NULL)

		  
    print 4
    print @op_date 
	INSERT INTO @TA (FID, FID_VERSION, SOURCE,REC_ID, RESORE_DOC_NO, RESTORE_DOC_DATE)
	  select D.FID, D.FID_VERSION, 4, D.REC_ID, FD.RESORE_DOC_NO, FD.RESTORE_DOC_DATE
	   from /*[172.17.250.10].*/[saesa_temp].[dbo].DECLARATIONS_V2_HISTORY D 
		inner join /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA_HISTORY FD 
		   on D.FID=FD.FID 
		     and FD.FID_VERSION=D.FID_VERSION
		left outer join /*[172.17.250.10].*/[saesa_temp].[dbo].FORM_3 F3 
		   on F3.FID=D.FID
		LEFT outer join [dbo].[LIVE_SCORES_OLD] AC 
		   on AC.FID=D.FID
		where ((D.ADD_DATE > @op_date -26) or EXISTS(SELECT NULL FROM /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA R WHERE (R.FID=D.FID) and ((LEGAL_SCORE_DATE > @op_date) or (R.ON_CONTROL = 1))))
		  and (D.REC_VERSION=3) 
		  and (FD.ON_CONTROL=0)
		  and (F3.FID is NULL)
		  and (AC.FID is NULL)

	
	
	print 5 
    print @op_date 
	INSERT INTO [dbo].[LIVE_SCORES_OLD]
			   ([FID]
			   ,[SOURCE] 
			   ,[REC_ID]	
			   ,[ITEM_NO]
			   ,[FAMILY_SCORE]
			   ,[REGION_ID]
			   ,[REGION] 
			   ,[ZIP_CODE]
			   ,[CITY]
			   ,[GOVERNMENT]
			   ,[VILLAGE]
			   ,[FULL_ADDRESS]
			   ,[PID]
			   ,[BIRTH_DATE]
			   ,[FIRST_NAME]
			   ,[LAST_NAME]
			   ,[AGE] 
			   ,[SEX] 
			   ,[ACTION_CODE]
			   ,[ACTION_DATE]
			   ,[SCORE_DATE]
			   ,[VISIT_DATE]
			   ,[RESORE_DOC_NO]
			   ,[RESTORE_DOC_DATE]
			   ,[IDENT] 
			   ,[SRA_ID])
	  select F.FID, 
	     T.SOURCE,
	     T.REC_ID,
	     P.ITEM_NO,
		 F.FAMILY_SCORE, 
		 F.REGION_ID, 
		 dbo.fn_con2utf8(F.REGION), 
		 F.ZIP_CODE, 
		 dbo.fn_con2utf8(F.CITY), 
		 dbo.fn_con2utf8(F.GOVERNMENT), 
		 dbo.fn_con2utf8(F.VILLAGE), 
		 dbo.fn_con2utf8(F.FULL_ADDRESS), 
		 P.PASS_ID as PID, 
		 P.BIRTH_DATE, 
		 dbo.fn_con2utf8(P.FIRST_NAME), 
		 dbo.fn_con2utf8(P.LAST_NAME), 
		 0,--P.AGE,
		 P.SEX,
		 P.ACTION_TYPE,
		 P.ACTION_DATE,
		 F.LEGAL_SCORE_DATE, 
		 F.VISIT_DATE,
		 T.RESORE_DOC_NO,
		 T.RESTORE_DOC_DATE, 
		 P.PIROBA,
		 P.J_ID  
	   from /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA_HISTORY F
		inner join /*[172.17.250.10].*/[saesa_temp].[dbo].FAMILY_DATA_PERSONS_HISTORY P 
		   on (P.FID=F.FID) 
		      and (P.FID_VERSION=F.FID_VERSION)
		inner join @TA T 
		   on (T.FID=F.FID) 
		     and (T.FID_VERSION=F.FID_VERSION)
		where (F.ON_CONTROL=0)
		  and (F.LEGAL_SCORE_DATE <= @op_date) 
		  --and (F.FAMILY_SCORE <70001)
		  --and (P.ACTION_TYPE is null or P.ACTION_TYPE='100')
		  and F.FID_VERSION=(select maX(FID_VERSION) from @TA TT where (TT.FID=F.FID) and (ON_CONTROL=0))

	print ' FINISH LIVESCORES!!! ' 
	print @op_date 


END
GO
/****** Object:  StoredProcedure [dbo].[GET_SCORES_BY_PIDS]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GET_SCORES_BY_PIDS]
(
  @PIDS PIDS READONLY
)
AS 
    BEGIN

        SET NOCOUNT ON;
		
		select A.PID, B.FAMILY_SCORE, B.SOURCE, B.SCORE_DATE, B.FULL_ADDRESS from  @PIDS A 
		left join [dbo].[LIVE_SCORES_F] B on A.PID = B.PID and (B.ACTION_CODE is null or B.ACTION_CODE = 100)
				
END
GO
/****** Object:  StoredProcedure [dbo].[SP_ADD_LOG]    Script Date: 10/04/2019 10:56:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO






CREATE PROCEDURE [dbo].[SP_ADD_LOG] 
			@PROCEDURE nvarchar(50),
			@COMMENT nvarchar(250)
            
AS BEGIN  
  INSERT INTO [dbo].[LIVE_LOG]([FROM_PROCEDURE],[COMMENT])
     VALUES (@PROCEDURE,@COMMENT)

 
END







GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "DECLARATION_FAMILY_V1V2_ARC"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 116
               Right = 224
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FAMILY_DATA_PERSONS'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FAMILY_DATA_PERSONS'
GO
