------------------------------------------------------------
IF 0 = (SELECT count(*) from [sysobjects] where ([xtype] = 'U' or [xtype] = 'V') and [name] = 'ut_BelFieldProperties')
BEGIN
CREATE TABLE [dbo].[ut_BelFieldProperties]
(
   [RecId]  integer NOT NULL
  ,[MandId] integer DEFAULT 1
  ,[FieldId] integer DEFAULT 0
  ,[FieldName] char(30) DEFAULT ' '
  ,[Grid] integer DEFAULT 0
  ,[Details] integer DEFAULT 0
  ,[Print] integer DEFAULT 0
  ,[Vorlauf] tinyint DEFAULT 0
  ,[Binary] tinyint DEFAULT 0
  ,[Virtual] tinyint DEFAULT 0
  ,[Prompt] char(30) DEFAULT ' '
  ,[Bez1] char(80) DEFAULT ' '
  ,[Bez2] char(80) DEFAULT ' '
  ,[Bez3] char(80) DEFAULT ' '
  ,[GridType] integer DEFAULT 0
  ,[GridWidth] integer DEFAULT 0
  ,[GridLimit] integer DEFAULT 0
  ,[GridDec] integer DEFAULT 0
  ,[GridColor] integer DEFAULT 0
  ,[Grid3D] tinyint DEFAULT 0
  ,[GridBk] tinyint DEFAULT 0
  ,[GridSearch] tinyint DEFAULT 0
  ,[GridEnabled] tinyint DEFAULT 0
  ,[FieldPos] integer DEFAULT 0
  ,[FieldPos1] integer DEFAULT 0
  ,[FieldPos4] integer DEFAULT 0
  ,[FieldPos6] integer DEFAULT 0
  ,[FieldPos7] integer DEFAULT 0
  ,[FieldPos8] integer DEFAULT 0
  CONSTRAINT [Pk_BelFieldProperties]  PRIMARY KEY NONCLUSTERED ( [RecId] )
)
END
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'TR'   and [name] = 'tr_BelFieldProperties_KeyDel')
  DROP TRIGGER [dbo].[tr_BelFieldProperties_KeyDel]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'TR'   and [name] = 'tr_BelFieldProperties_KeyUpd')
  DROP TRIGGER [dbo].[tr_BelFieldProperties_KeyUpd]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'U' and [name] = 'ut_BelFieldProperties_Keys')
  DROP TABLE [dbo].[ut_BelFieldProperties_Keys]
GO

IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldId')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [FieldId] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldName')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [FieldName] char(30) NOT NULL DEFAULT ' '
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Grid')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Grid] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Details')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Details] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Print')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Print] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Vorlauf')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Vorlauf] tinyint NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Binary')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Binary] tinyint NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Virtual')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Virtual] tinyint NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Prompt')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Prompt] char(30) NOT NULL DEFAULT ' '
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Bez1')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Bez1] char(80) NOT NULL DEFAULT ' '
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Bez2')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Bez2] char(80) NOT NULL DEFAULT ' '
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Bez3')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Bez3] char(80) NOT NULL DEFAULT ' '
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'GridType')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [GridType] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'GridWidth')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [GridWidth] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'GridLimit')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [GridLimit] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'GridDec')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [GridDec] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'GridColor')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [GridColor] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Grid3D')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [Grid3D] tinyint NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'GridBk')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [GridBk] tinyint NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'GridSearch')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [GridSearch] tinyint NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'GridEnabled')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [GridEnabled] tinyint NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldPos')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [FieldPos] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldPos1')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [FieldPos1] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldPos4')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [FieldPos4] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldPos6')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [FieldPos6] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldPos7')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [FieldPos7] integer NOT NULL DEFAULT 0
END
GO
IF 0 = (select count(*) from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldPos8')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ADD [FieldPos8] integer NOT NULL DEFAULT 0
END
GO
IF 30 > (select length from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'FieldName')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ALTER COLUMN [FieldName] char(30)
END
GO
IF 30 > (select length from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Prompt')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ALTER COLUMN [Prompt] char(30)
END
GO
IF 80 > (select length from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Bez1')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ALTER COLUMN [Bez1] char(80)
END
GO
IF 80 > (select length from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Bez2')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ALTER COLUMN [Bez2] char(80)
END
GO
IF 80 > (select length from syscolumns sc inner join sysobjects so
        on sc.[id] = so.[id] and so.[name] = 'ut_BelFieldProperties' and sc.[name] = 'Bez3')
BEGIN
  ALTER TABLE [dbo].[ut_BelFieldProperties] ALTER COLUMN [Bez3] char(80)
END
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'V' and [name] = 'BelFieldProperties')
  DROP VIEW [dbo].[BelFieldProperties]
GO
CREATE VIEW [dbo].[BelFieldProperties] AS
  SELECT * FROM [dbo].[ut_BelFieldProperties]
GO
CREATE TABLE [dbo].[ut_BelFieldProperties_Keys]
(
   [DataRecId]  integer NOT NULL
  ,[DataMandId] integer DEFAULT 1
  ,[Key00_Value] CHAR(14) NOT NULL
  ,[Key01_Filter] TINYINT NOT NULL
  ,[Key01_Value] CHAR(14) NOT NULL
  ,[Key02_Value] CHAR(40) NOT NULL
  ,[Key03_Filter] TINYINT NOT NULL
  ,[Key03_Value] CHAR(14) NOT NULL
  ,[Key04_Filter] TINYINT NOT NULL
  ,[Key04_Value] CHAR(14) NOT NULL
  ,[Key05_Filter] TINYINT NOT NULL
  ,[Key05_Value] CHAR(14) NOT NULL
  ,[Key06_Filter] TINYINT NOT NULL
  ,[Key06_Value] CHAR(14) NOT NULL
  ,[Key07_Filter] TINYINT NOT NULL
  ,[Key07_Value] CHAR(14) NOT NULL
  CONSTRAINT [Pk_ut_BelFieldProperties_Keys]  PRIMARY KEY NONCLUSTERED ( [DataRecId] )
)
GO
CREATE TRIGGER [dbo].[tr_BelFieldProperties_KeyDel] ON [dbo].[ut_BelFieldProperties]
FOR DELETE
AS
  SET NOCOUNT ON
  DELETE FROM [dbo].[ut_BelFieldProperties_Keys] WITH (SERIALIZABLE)
  WHERE [DataRecId] IN (SELECT [RecId] FROM DELETED)
GO

CREATE TRIGGER [dbo].[tr_BelFieldProperties_KeyUpd] ON [dbo].[ut_BelFieldProperties]
FOR INSERT, UPDATE
AS
  SET NOCOUNT ON
  IF UPDATE([RecId]) OR UPDATE([MandId])
  BEGIN
    DELETE FROM [dbo].[ut_BelFieldProperties_Keys] WITH (SERIALIZABLE)
    WHERE [DataRecId] IN (SELECT [RecId] FROM DELETED)

    INSERT INTO [dbo].[ut_BelFieldProperties_Keys] WITH (SERIALIZABLE)
    ([DataRecId],[DataMandId],[Key00_Value],[Key01_Filter],[Key01_Value],[Key02_Value],[Key03_Filter],[Key03_Value],[Key04_Filter],[Key04_Value],[Key05_Filter],[Key05_Value],[Key06_Filter],[Key06_Value],[Key07_Filter],[Key07_Value])
    (SELECT [RecId],[MandId]
     ,UPPER(STR([FieldId],4,0)+STR(RecId,10))
     ,CASE WHEN Grid > 0 THEN 1 ELSE 0 END
     ,UPPER(STR([FieldPos],4,0)+STR(RecId,10))
     ,UPPER(convert(char(30),[FieldName])+STR(RecId,10))
     ,CASE WHEN FieldPos1 > 0 THEN 1 ELSE 0 END
     ,UPPER(STR([FieldPos1],4,0)+STR(RecId,10))
     ,CASE WHEN FieldPos4 > 0 THEN 1 ELSE 0 END
     ,UPPER(STR([FieldPos4],4,0)+STR(RecId,10))
     ,CASE WHEN FieldPos6 > 0 THEN 1 ELSE 0 END
     ,UPPER(STR([FieldPos6],4,0)+STR(RecId,10))
     ,CASE WHEN FieldPos7 > 0 THEN 1 ELSE 0 END
     ,UPPER(STR([FieldPos6],4,0)+STR(RecId,10))
     ,CASE WHEN FieldPos8 > 0 THEN 1 ELSE 0 END
     ,UPPER(STR([FieldPos6],4,0)+STR(RecId,10))

    FROM INSERTED)
  END
  ELSE
  BEGIN
    UPDATE [dbo].[ut_BelFieldProperties_Keys] WITH (SERIALIZABLE) SET
    [Key00_Value] = UPPER(STR([FieldId],4,0)+STR([RecId],10))
   ,[Key01_Value] = UPPER(STR([FieldPos],4,0)+STR([RecId],10))
   ,[Key01_Filter] = CASE WHEN Grid > 0 THEN 1 ELSE 0 END
   ,[Key02_Value] = UPPER(convert(char(30),[FieldName])+STR([RecId],10))
   ,[Key03_Value] = UPPER(STR([FieldPos1],4,0)+STR([RecId],10))
   ,[Key03_Filter] = CASE WHEN FieldPos1 > 0 THEN 1 ELSE 0 END
   ,[Key04_Value] = UPPER(STR([FieldPos4],4,0)+STR([RecId],10))
   ,[Key04_Filter] = CASE WHEN FieldPos4 > 0 THEN 1 ELSE 0 END
   ,[Key05_Value] = UPPER(STR([FieldPos6],4,0)+STR([RecId],10))
   ,[Key05_Filter] = CASE WHEN FieldPos6 > 0 THEN 1 ELSE 0 END
   ,[Key06_Value] = UPPER(STR([FieldPos6],4,0)+STR([RecId],10))
   ,[Key06_Filter] = CASE WHEN FieldPos7 > 0 THEN 1 ELSE 0 END
   ,[Key07_Value] = UPPER(STR([FieldPos6],4,0)+STR([RecId],10))
   ,[Key07_Filter] = CASE WHEN FieldPos8 > 0 THEN 1 ELSE 0 END
    FROM INSERTED WHERE [DataRecId] = [RecId]
  END
GO

UPDATE [dbo].[ut_BelFieldProperties] SET RecId = RecId
GO


------------------------------------------------------------
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Add_BelFieldProperties')
  DROP PROCEDURE [dbo].[up_Add_BelFieldProperties]
GO
CREATE PROCEDURE [dbo].[up_Add_BelFieldProperties] AS
  DECLARE @NeueId integer
  SET @NeueId = (SELECT MAX(RecId) from [dbo].[ut_BelFieldProperties])
  IF @NeueId IS NULL SET @NeueId = 0
  SET @NeueId = @NeueId + 1
  INSERT INTO [dbo].[ut_BelFieldProperties] (RecId) VALUES( @NeueId )
  IF @@ERROR = 0
  BEGIN
    SELECT @NeueId AS RecId
    RETURN
  END
  SELECT 0 AS RecId
GO

------------------------------------------------------------
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Upd_BelFieldProperties')
  DROP PROCEDURE [dbo].[up_Upd_BelFieldProperties]
GO
CREATE PROCEDURE [dbo].[up_Upd_BelFieldProperties]
  @RI integer
 ,@Parm_FieldId integer
 ,@Parm_FieldName char(30)
 ,@Parm_Grid integer
 ,@Parm_Details integer
 ,@Parm_Print integer
 ,@Parm_Vorlauf tinyint
 ,@Parm_Binary tinyint
 ,@Parm_Virtual tinyint
 ,@Parm_Prompt char(30)
 ,@Parm_Bez1 char(80)
 ,@Parm_Bez2 char(80)
 ,@Parm_Bez3 char(80)
 ,@Parm_GridType integer
 ,@Parm_GridWidth integer
 ,@Parm_GridLimit integer
 ,@Parm_GridDec integer
 ,@Parm_GridColor integer
 ,@Parm_Grid3D tinyint
 ,@Parm_GridBk tinyint
 ,@Parm_GridSearch tinyint
 ,@Parm_GridEnabled tinyint
 ,@Parm_FieldPos integer
 ,@Parm_FieldPos1 integer
 ,@Parm_FieldPos4 integer
 ,@Parm_FieldPos6 integer
 ,@Parm_FieldPos7 integer
 ,@Parm_FieldPos8 integer
AS
--BEGIN TRANSACTION
UPDATE [dbo].[ut_BelFieldProperties] SET
     [FieldId] = @Parm_FieldId
    ,[FieldName] = RTRIM(@Parm_FieldName)
    ,[Grid] = @Parm_Grid
    ,[Details] = @Parm_Details
    ,[Print] = @Parm_Print
    ,[Vorlauf] = @Parm_Vorlauf
    ,[Binary] = @Parm_Binary
    ,[Virtual] = @Parm_Virtual
    ,[Prompt] = RTRIM(@Parm_Prompt)
    ,[Bez1] = RTRIM(@Parm_Bez1)
    ,[Bez2] = RTRIM(@Parm_Bez2)
    ,[Bez3] = RTRIM(@Parm_Bez3)
    ,[GridType] = @Parm_GridType
    ,[GridWidth] = @Parm_GridWidth
    ,[GridLimit] = @Parm_GridLimit
    ,[GridDec] = @Parm_GridDec
    ,[GridColor] = @Parm_GridColor
    ,[Grid3D] = @Parm_Grid3D
    ,[GridBk] = @Parm_GridBk
    ,[GridSearch] = @Parm_GridSearch
    ,[GridEnabled] = @Parm_GridEnabled
    ,[FieldPos] = @Parm_FieldPos
    ,[FieldPos1] = @Parm_FieldPos1
    ,[FieldPos4] = @Parm_FieldPos4
    ,[FieldPos6] = @Parm_FieldPos6
    ,[FieldPos7] = @Parm_FieldPos7
    ,[FieldPos8] = @Parm_FieldPos8
  WHERE RecId = @RI
--COMMIT TRANSACTION
GO

------------------------------------------------------------
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Sel_BelFieldProperties')
  DROP PROCEDURE [dbo].[up_Sel_BelFieldProperties]
GO
CREATE PROCEDURE [dbo].[up_Sel_BelFieldProperties]
  @RI integer
AS
SELECT
     [FieldId]
    ,[FieldName]
    ,[Grid]
    ,[Details]
    ,[Print]
    ,[Vorlauf]
    ,[Binary]
    ,[Virtual]
    ,[Prompt]
    ,[Bez1]
    ,[Bez2]
    ,[Bez3]
    ,[GridType]
    ,[GridWidth]
    ,[GridLimit]
    ,[GridDec]
    ,[GridColor]
    ,[Grid3D]
    ,[GridBk]
    ,[GridSearch]
    ,[GridEnabled]
    ,[FieldPos]
    ,[FieldPos1]
    ,[FieldPos4]
    ,[FieldPos6]
    ,[FieldPos7]
    ,[FieldPos8]
  FROM [dbo].[ut_BelFieldProperties]
  WHERE RecId = @RI
GO
------------------------------------------------------------
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Del_BelFieldProperties')
  DROP PROCEDURE [dbo].[up_Del_BelFieldProperties]
GO
CREATE PROCEDURE [dbo].[up_Del_BelFieldProperties]
  @RI integer
AS
  DELETE FROM [dbo].[ut_BelFieldProperties] WHERE RecId = @RI
GO
------------------------------------------------------------
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Reorg_BelFieldProperties')
  DROP PROCEDURE [dbo].[up_Reorg_BelFieldProperties]
GO
CREATE PROCEDURE [dbo].[up_Reorg_BelFieldProperties]
  @bDbcc integer,@bRecId integer
AS
  IF (@bRecId = 1)
  BEGIN
    DECLARE  C        CURSOR FOR SELECT RecId FROM [dbo].[ut_BelFieldProperties] ORDER BY RecId
    DECLARE  @CurrId  integer
    DECLARE  @NextId  integer
    --BEGIN TRANSACTION
    OPEN C
    SET @NextId = 1
    FETCH NEXT FROM C INTO @CurrId
    WHILE (@@FETCH_STATUS = 0)
    BEGIN
      IF @CurrId <> @NextId
      UPDATE [dbo].[ut_BelFieldProperties] SET RecId=@NextId WHERE CURRENT OF C
      SET @NextId = @NextId + 1
      FETCH NEXT FROM C INTO @CurrId
    END
    CLOSE C
    --COMMIT TRANSACTION
    DEALLOCATE C
  END

  IF (@bDbcc = 1)
  BEGIN
    DBCC DBREINDEX ( [ut_BelFieldProperties] )
  END

GO

------------------------------------------------------------
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Append_BelFieldProperties')
  DROP PROCEDURE [dbo].[up_Append_BelFieldProperties]
GO
CREATE PROCEDURE [dbo].[up_Append_BelFieldProperties]
  @Parm_FieldId integer
 ,@Parm_FieldName char(30)
 ,@Parm_Grid integer
 ,@Parm_Details integer
 ,@Parm_Print integer
 ,@Parm_Vorlauf tinyint
 ,@Parm_Binary tinyint
 ,@Parm_Virtual tinyint
 ,@Parm_Prompt char(30)
 ,@Parm_Bez1 char(80)
 ,@Parm_Bez2 char(80)
 ,@Parm_Bez3 char(80)
 ,@Parm_GridType integer
 ,@Parm_GridWidth integer
 ,@Parm_GridLimit integer
 ,@Parm_GridDec integer
 ,@Parm_GridColor integer
 ,@Parm_Grid3D tinyint
 ,@Parm_GridBk tinyint
 ,@Parm_GridSearch tinyint
 ,@Parm_GridEnabled tinyint
 ,@Parm_FieldPos integer
 ,@Parm_FieldPos1 integer
 ,@Parm_FieldPos4 integer
 ,@Parm_FieldPos6 integer
 ,@Parm_FieldPos7 integer
 ,@Parm_FieldPos8 integer
AS
  DECLARE @NeueId    integer
  SET     @NeueId = (SELECT MAX(RecId) FROM [dbo].[ut_BelFieldProperties])
  IF @NeueId IS NULL SET @NeueId = 0
  SET @NeueId = @NeueId + 1
  INSERT INTO [dbo].[ut_BelFieldProperties] (
    RecId
   ,[FieldId]
   ,[FieldName]
   ,[Grid]
   ,[Details]
   ,[Print]
   ,[Vorlauf]
   ,[Binary]
   ,[Virtual]
   ,[Prompt]
   ,[Bez1]
   ,[Bez2]
   ,[Bez3]
   ,[GridType]
   ,[GridWidth]
   ,[GridLimit]
   ,[GridDec]
   ,[GridColor]
   ,[Grid3D]
   ,[GridBk]
   ,[GridSearch]
   ,[GridEnabled]
   ,[FieldPos]
   ,[FieldPos1]
   ,[FieldPos4]
   ,[FieldPos6]
   ,[FieldPos7]
   ,[FieldPos8]
     ) VALUES (
    @NeueId
   ,@Parm_FieldId
   ,RTRIM(@Parm_FieldName)
   ,@Parm_Grid
   ,@Parm_Details
   ,@Parm_Print
   ,@Parm_Vorlauf
   ,@Parm_Binary
   ,@Parm_Virtual
   ,RTRIM(@Parm_Prompt)
   ,RTRIM(@Parm_Bez1)
   ,RTRIM(@Parm_Bez2)
   ,RTRIM(@Parm_Bez3)
   ,@Parm_GridType
   ,@Parm_GridWidth
   ,@Parm_GridLimit
   ,@Parm_GridDec
   ,@Parm_GridColor
   ,@Parm_Grid3D
   ,@Parm_GridBk
   ,@Parm_GridSearch
   ,@Parm_GridEnabled
   ,@Parm_FieldPos
   ,@Parm_FieldPos1
   ,@Parm_FieldPos4
   ,@Parm_FieldPos6
   ,@Parm_FieldPos7
   ,@Parm_FieldPos8
       )
  IF @@ERROR = 0
  BEGIN
    SELECT @NeueId AS RecId
    RETURN
  END
  SELECT 0 AS RecId
GO

------------------------------------------------------------
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_TrSel_BelFieldProperties')
  DROP PROCEDURE [dbo].[up_TrSel_BelFieldProperties]
GO
CREATE PROCEDURE [dbo].[up_TrSel_BelFieldProperties]
AS
  SELECT   RecId,
      LTRIM(RTRIM([FieldName]))
      +LTRIM(RTRIM([Prompt]))
      +LTRIM(RTRIM([Bez1]))
      +LTRIM(RTRIM([Bez2]))
      +LTRIM(RTRIM([Bez3]))
    AS Data
  FROM     [dbo].[ut_BelFieldProperties]
  WHERE    RecId > 0
  ORDER BY RecId
GO

CREATE INDEX [Ik_Key00] ON [dbo].[ut_BelFieldProperties_Keys]
( [Key00_Value],[DataRecId] )
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_BelFieldProperties_Key00')
  DROP PROCEDURE [dbo].[up_First_BelFieldProperties_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_BelFieldProperties_Key00')
  DROP PROCEDURE [dbo].[up_Last_BelFieldProperties_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_BelFieldProperties_Key00')
  DROP PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_BelFieldProperties_Key00')
  DROP PROCEDURE [dbo].[up_Next_BelFieldProperties_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior50_BelFieldProperties_Key00')
  DROP PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next50_BelFieldProperties_Key00')
  DROP PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindL_BelFieldProperties_Key00')
  DROP PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindF_BelFieldProperties_Key00')
  DROP PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key00]
GO

CREATE PROCEDURE [dbo].[up_First_BelFieldProperties_Key00]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys] ORDER BY [Key00_Value]
GO

CREATE PROCEDURE [dbo].[up_Last_BelFieldProperties_Key00]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys] ORDER BY [Key00_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next_BelFieldProperties_Key00] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key00_Value] > (SELECT [Key00_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key00_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key00] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key00_Value] < (SELECT [Key00_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key00_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key00] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key00_Value] > (SELECT [Key00_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key00_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key00] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key00_Value] < (SELECT [Key00_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key00_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key00] @xKey char(128),@xLen integer
AS
  SELECT a.[DataRecId] FROM
    ( SELECT TOP 1 [DataRecId],[Key00_Value] AS Key_Value FROM [dbo].[ut_BelFieldProperties_Keys]
      WHERE [Key00_Value] >= SUBSTRING(@xKey,1,@xLen)
      ORDER BY [Key00_Value]
    ) a
  WHERE a.Key_Value like SUBSTRING(@xKey,1,@xLen)+'%'
GO

CREATE PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key00] @xKey char(128),@xLen integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key00_Value] like SUBSTRING(@xKey,1,@xLen)+'%'
  ORDER BY [Key00_Value] DESC
GO

CREATE INDEX [Ik_Key01] ON [dbo].[ut_BelFieldProperties_Keys]
( [Key01_Filter],[Key01_Value],[DataRecId] )
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_BelFieldProperties_Key01')
  DROP PROCEDURE [dbo].[up_First_BelFieldProperties_Key01]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_BelFieldProperties_Key01')
  DROP PROCEDURE [dbo].[up_Last_BelFieldProperties_Key01]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_BelFieldProperties_Key01')
  DROP PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key01]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_BelFieldProperties_Key01')
  DROP PROCEDURE [dbo].[up_Next_BelFieldProperties_Key01]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior50_BelFieldProperties_Key01')
  DROP PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key01]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next50_BelFieldProperties_Key01')
  DROP PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key01]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindL_BelFieldProperties_Key01')
  DROP PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key01]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindF_BelFieldProperties_Key01')
  DROP PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key01]
GO

CREATE PROCEDURE [dbo].[up_First_BelFieldProperties_Key01]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key01_Filter] = 1 ORDER BY [Key01_Value]
GO

CREATE PROCEDURE [dbo].[up_Last_BelFieldProperties_Key01]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key01_Filter] = 1 ORDER BY [Key01_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next_BelFieldProperties_Key01] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key01_Filter] = 1 AND [Key01_Value] > (SELECT [Key01_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key01_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key01] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key01_Filter] = 1 AND [Key01_Value] < (SELECT [Key01_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key01_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key01] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key01_Filter] = 1 AND [Key01_Value] > (SELECT [Key01_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key01_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key01] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key01_Filter] = 1 AND [Key01_Value] < (SELECT [Key01_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key01_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key01] @xKey char(128),@xLen integer
AS
  SELECT a.[DataRecId] FROM
    ( SELECT TOP 1 [DataRecId],[Key01_Value] AS Key_Value FROM [dbo].[ut_BelFieldProperties_Keys]
      WHERE [Key01_Filter] = 1 AND [Key01_Value] >= SUBSTRING(@xKey,1,@xLen)
      ORDER BY [Key01_Value]
    ) a
  WHERE a.Key_Value like SUBSTRING(@xKey,1,@xLen)+'%'
GO

CREATE PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key01] @xKey char(128),@xLen integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key01_Filter] = 1 AND [Key01_Value] like SUBSTRING(@xKey,1,@xLen)+'%'
  ORDER BY [Key01_Value] DESC
GO

CREATE INDEX [Ik_Key02] ON [dbo].[ut_BelFieldProperties_Keys]
( [Key02_Value],[DataRecId] )
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_BelFieldProperties_Key02')
  DROP PROCEDURE [dbo].[up_First_BelFieldProperties_Key02]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_BelFieldProperties_Key02')
  DROP PROCEDURE [dbo].[up_Last_BelFieldProperties_Key02]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_BelFieldProperties_Key02')
  DROP PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key02]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_BelFieldProperties_Key02')
  DROP PROCEDURE [dbo].[up_Next_BelFieldProperties_Key02]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior50_BelFieldProperties_Key02')
  DROP PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key02]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next50_BelFieldProperties_Key02')
  DROP PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key02]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindL_BelFieldProperties_Key02')
  DROP PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key02]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindF_BelFieldProperties_Key02')
  DROP PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key02]
GO

CREATE PROCEDURE [dbo].[up_First_BelFieldProperties_Key02]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys] ORDER BY [Key02_Value]
GO

CREATE PROCEDURE [dbo].[up_Last_BelFieldProperties_Key02]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys] ORDER BY [Key02_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next_BelFieldProperties_Key02] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key02_Value] > (SELECT [Key02_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key02_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key02] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key02_Value] < (SELECT [Key02_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key02_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key02] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key02_Value] > (SELECT [Key02_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key02_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key02] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key02_Value] < (SELECT [Key02_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key02_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key02] @xKey char(128),@xLen integer
AS
  SELECT a.[DataRecId] FROM
    ( SELECT TOP 1 [DataRecId],[Key02_Value] AS Key_Value FROM [dbo].[ut_BelFieldProperties_Keys]
      WHERE [Key02_Value] >= SUBSTRING(@xKey,1,@xLen)
      ORDER BY [Key02_Value]
    ) a
  WHERE a.Key_Value like SUBSTRING(@xKey,1,@xLen)+'%'
GO

CREATE PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key02] @xKey char(128),@xLen integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key02_Value] like SUBSTRING(@xKey,1,@xLen)+'%'
  ORDER BY [Key02_Value] DESC
GO

CREATE INDEX [Ik_Key03] ON [dbo].[ut_BelFieldProperties_Keys]
( [Key03_Filter],[Key03_Value],[DataRecId] )
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_BelFieldProperties_Key03')
  DROP PROCEDURE [dbo].[up_First_BelFieldProperties_Key03]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_BelFieldProperties_Key03')
  DROP PROCEDURE [dbo].[up_Last_BelFieldProperties_Key03]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_BelFieldProperties_Key03')
  DROP PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key03]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_BelFieldProperties_Key03')
  DROP PROCEDURE [dbo].[up_Next_BelFieldProperties_Key03]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior50_BelFieldProperties_Key03')
  DROP PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key03]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next50_BelFieldProperties_Key03')
  DROP PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key03]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindL_BelFieldProperties_Key03')
  DROP PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key03]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindF_BelFieldProperties_Key03')
  DROP PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key03]
GO

CREATE PROCEDURE [dbo].[up_First_BelFieldProperties_Key03]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key03_Filter] = 1 ORDER BY [Key03_Value]
GO

CREATE PROCEDURE [dbo].[up_Last_BelFieldProperties_Key03]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key03_Filter] = 1 ORDER BY [Key03_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next_BelFieldProperties_Key03] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key03_Filter] = 1 AND [Key03_Value] > (SELECT [Key03_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key03_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key03] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key03_Filter] = 1 AND [Key03_Value] < (SELECT [Key03_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key03_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key03] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key03_Filter] = 1 AND [Key03_Value] > (SELECT [Key03_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key03_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key03] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key03_Filter] = 1 AND [Key03_Value] < (SELECT [Key03_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key03_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key03] @xKey char(128),@xLen integer
AS
  SELECT a.[DataRecId] FROM
    ( SELECT TOP 1 [DataRecId],[Key03_Value] AS Key_Value FROM [dbo].[ut_BelFieldProperties_Keys]
      WHERE [Key03_Filter] = 1 AND [Key03_Value] >= SUBSTRING(@xKey,1,@xLen)
      ORDER BY [Key03_Value]
    ) a
  WHERE a.Key_Value like SUBSTRING(@xKey,1,@xLen)+'%'
GO

CREATE PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key03] @xKey char(128),@xLen integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key03_Filter] = 1 AND [Key03_Value] like SUBSTRING(@xKey,1,@xLen)+'%'
  ORDER BY [Key03_Value] DESC
GO

CREATE INDEX [Ik_Key04] ON [dbo].[ut_BelFieldProperties_Keys]
( [Key04_Filter],[Key04_Value],[DataRecId] )
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_BelFieldProperties_Key04')
  DROP PROCEDURE [dbo].[up_First_BelFieldProperties_Key04]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_BelFieldProperties_Key04')
  DROP PROCEDURE [dbo].[up_Last_BelFieldProperties_Key04]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_BelFieldProperties_Key04')
  DROP PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key04]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_BelFieldProperties_Key04')
  DROP PROCEDURE [dbo].[up_Next_BelFieldProperties_Key04]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior50_BelFieldProperties_Key04')
  DROP PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key04]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next50_BelFieldProperties_Key04')
  DROP PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key04]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindL_BelFieldProperties_Key04')
  DROP PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key04]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindF_BelFieldProperties_Key04')
  DROP PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key04]
GO

CREATE PROCEDURE [dbo].[up_First_BelFieldProperties_Key04]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key04_Filter] = 1 ORDER BY [Key04_Value]
GO

CREATE PROCEDURE [dbo].[up_Last_BelFieldProperties_Key04]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key04_Filter] = 1 ORDER BY [Key04_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next_BelFieldProperties_Key04] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key04_Filter] = 1 AND [Key04_Value] > (SELECT [Key04_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key04_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key04] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key04_Filter] = 1 AND [Key04_Value] < (SELECT [Key04_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key04_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key04] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key04_Filter] = 1 AND [Key04_Value] > (SELECT [Key04_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key04_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key04] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key04_Filter] = 1 AND [Key04_Value] < (SELECT [Key04_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key04_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key04] @xKey char(128),@xLen integer
AS
  SELECT a.[DataRecId] FROM
    ( SELECT TOP 1 [DataRecId],[Key04_Value] AS Key_Value FROM [dbo].[ut_BelFieldProperties_Keys]
      WHERE [Key04_Filter] = 1 AND [Key04_Value] >= SUBSTRING(@xKey,1,@xLen)
      ORDER BY [Key04_Value]
    ) a
  WHERE a.Key_Value like SUBSTRING(@xKey,1,@xLen)+'%'
GO

CREATE PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key04] @xKey char(128),@xLen integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key04_Filter] = 1 AND [Key04_Value] like SUBSTRING(@xKey,1,@xLen)+'%'
  ORDER BY [Key04_Value] DESC
GO

CREATE INDEX [Ik_Key05] ON [dbo].[ut_BelFieldProperties_Keys]
( [Key05_Filter],[Key05_Value],[DataRecId] )
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_BelFieldProperties_Key05')
  DROP PROCEDURE [dbo].[up_First_BelFieldProperties_Key05]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_BelFieldProperties_Key05')
  DROP PROCEDURE [dbo].[up_Last_BelFieldProperties_Key05]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_BelFieldProperties_Key05')
  DROP PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key05]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_BelFieldProperties_Key05')
  DROP PROCEDURE [dbo].[up_Next_BelFieldProperties_Key05]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior50_BelFieldProperties_Key05')
  DROP PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key05]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next50_BelFieldProperties_Key05')
  DROP PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key05]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindL_BelFieldProperties_Key05')
  DROP PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key05]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindF_BelFieldProperties_Key05')
  DROP PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key05]
GO

CREATE PROCEDURE [dbo].[up_First_BelFieldProperties_Key05]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key05_Filter] = 1 ORDER BY [Key05_Value]
GO

CREATE PROCEDURE [dbo].[up_Last_BelFieldProperties_Key05]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key05_Filter] = 1 ORDER BY [Key05_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next_BelFieldProperties_Key05] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key05_Filter] = 1 AND [Key05_Value] > (SELECT [Key05_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key05_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key05] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key05_Filter] = 1 AND [Key05_Value] < (SELECT [Key05_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key05_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key05] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key05_Filter] = 1 AND [Key05_Value] > (SELECT [Key05_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key05_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key05] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key05_Filter] = 1 AND [Key05_Value] < (SELECT [Key05_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key05_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key05] @xKey char(128),@xLen integer
AS
  SELECT a.[DataRecId] FROM
    ( SELECT TOP 1 [DataRecId],[Key05_Value] AS Key_Value FROM [dbo].[ut_BelFieldProperties_Keys]
      WHERE [Key05_Filter] = 1 AND [Key05_Value] >= SUBSTRING(@xKey,1,@xLen)
      ORDER BY [Key05_Value]
    ) a
  WHERE a.Key_Value like SUBSTRING(@xKey,1,@xLen)+'%'
GO

CREATE PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key05] @xKey char(128),@xLen integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key05_Filter] = 1 AND [Key05_Value] like SUBSTRING(@xKey,1,@xLen)+'%'
  ORDER BY [Key05_Value] DESC
GO

CREATE INDEX [Ik_Key06] ON [dbo].[ut_BelFieldProperties_Keys]
( [Key06_Filter],[Key06_Value],[DataRecId] )
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_BelFieldProperties_Key06')
  DROP PROCEDURE [dbo].[up_First_BelFieldProperties_Key06]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_BelFieldProperties_Key06')
  DROP PROCEDURE [dbo].[up_Last_BelFieldProperties_Key06]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_BelFieldProperties_Key06')
  DROP PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key06]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_BelFieldProperties_Key06')
  DROP PROCEDURE [dbo].[up_Next_BelFieldProperties_Key06]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior50_BelFieldProperties_Key06')
  DROP PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key06]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next50_BelFieldProperties_Key06')
  DROP PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key06]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindL_BelFieldProperties_Key06')
  DROP PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key06]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindF_BelFieldProperties_Key06')
  DROP PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key06]
GO

CREATE PROCEDURE [dbo].[up_First_BelFieldProperties_Key06]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key06_Filter] = 1 ORDER BY [Key06_Value]
GO

CREATE PROCEDURE [dbo].[up_Last_BelFieldProperties_Key06]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key06_Filter] = 1 ORDER BY [Key06_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next_BelFieldProperties_Key06] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key06_Filter] = 1 AND [Key06_Value] > (SELECT [Key06_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key06_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key06] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key06_Filter] = 1 AND [Key06_Value] < (SELECT [Key06_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key06_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key06] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key06_Filter] = 1 AND [Key06_Value] > (SELECT [Key06_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key06_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key06] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key06_Filter] = 1 AND [Key06_Value] < (SELECT [Key06_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key06_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key06] @xKey char(128),@xLen integer
AS
  SELECT a.[DataRecId] FROM
    ( SELECT TOP 1 [DataRecId],[Key06_Value] AS Key_Value FROM [dbo].[ut_BelFieldProperties_Keys]
      WHERE [Key06_Filter] = 1 AND [Key06_Value] >= SUBSTRING(@xKey,1,@xLen)
      ORDER BY [Key06_Value]
    ) a
  WHERE a.Key_Value like SUBSTRING(@xKey,1,@xLen)+'%'
GO

CREATE PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key06] @xKey char(128),@xLen integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key06_Filter] = 1 AND [Key06_Value] like SUBSTRING(@xKey,1,@xLen)+'%'
  ORDER BY [Key06_Value] DESC
GO

CREATE INDEX [Ik_Key07] ON [dbo].[ut_BelFieldProperties_Keys]
( [Key07_Filter],[Key07_Value],[DataRecId] )
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_BelFieldProperties_Key07')
  DROP PROCEDURE [dbo].[up_First_BelFieldProperties_Key07]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_BelFieldProperties_Key07')
  DROP PROCEDURE [dbo].[up_Last_BelFieldProperties_Key07]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_BelFieldProperties_Key07')
  DROP PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key07]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_BelFieldProperties_Key07')
  DROP PROCEDURE [dbo].[up_Next_BelFieldProperties_Key07]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior50_BelFieldProperties_Key07')
  DROP PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key07]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next50_BelFieldProperties_Key07')
  DROP PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key07]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindL_BelFieldProperties_Key07')
  DROP PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key07]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_FindF_BelFieldProperties_Key07')
  DROP PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key07]
GO

CREATE PROCEDURE [dbo].[up_First_BelFieldProperties_Key07]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key07_Filter] = 1 ORDER BY [Key07_Value]
GO

CREATE PROCEDURE [dbo].[up_Last_BelFieldProperties_Key07]
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key07_Filter] = 1 ORDER BY [Key07_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next_BelFieldProperties_Key07] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key07_Filter] = 1 AND [Key07_Value] > (SELECT [Key07_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key07_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior_BelFieldProperties_Key07] @mRecNo integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key07_Filter] = 1 AND [Key07_Value] < (SELECT [Key07_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key07_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_Next50_BelFieldProperties_Key07] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key07_Filter] = 1 AND [Key07_Value] > (SELECT [Key07_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key07_Value]
GO

CREATE PROCEDURE [dbo].[up_Prior50_BelFieldProperties_Key07] @mRecNo integer
AS
  SELECT TOP 50 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key07_Filter] = 1 AND [Key07_Value] < (SELECT [Key07_Value] FROM [dbo].[ut_BelFieldProperties_Keys] WHERE [DataRecId] = @mRecNo)
  ORDER BY [Key07_Value] DESC
GO

CREATE PROCEDURE [dbo].[up_FindF_BelFieldProperties_Key07] @xKey char(128),@xLen integer
AS
  SELECT a.[DataRecId] FROM
    ( SELECT TOP 1 [DataRecId],[Key07_Value] AS Key_Value FROM [dbo].[ut_BelFieldProperties_Keys]
      WHERE [Key07_Filter] = 1 AND [Key07_Value] >= SUBSTRING(@xKey,1,@xLen)
      ORDER BY [Key07_Value]
    ) a
  WHERE a.Key_Value like SUBSTRING(@xKey,1,@xLen)+'%'
GO

CREATE PROCEDURE [dbo].[up_FindL_BelFieldProperties_Key07] @xKey char(128),@xLen integer
AS
  SELECT TOP 1 [DataRecId] FROM [dbo].[ut_BelFieldProperties_Keys]
  WHERE [Key07_Filter] = 1 AND [Key07_Value] like SUBSTRING(@xKey,1,@xLen)+'%'
  ORDER BY [Key07_Value] DESC
GO

