Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
titlePopulating nForm Lookups and Lookup Values from a Source Table
DECLARE @LOOKUP_ID UNIQUEIDENTIFIER

SET @LOOKUP_ID = NEWID()

INSERT INTO NFORM.LOOKUP
        ( LOOKUP_ID ,
          NAME ,
          CREATED_DATE ,
          CREATED_USER ,
          UPDATED_DATE ,
          UPDATED_USER ,
          IS_AVAILABLE_FOR_DROPDOWN
        )
SELECT @LOOKUP_ID, -- LOOKUP_ID - uniqueidentifier
          N'COLORS' , -- NAME - nvarchar(255)
          GETDATE() , -- CREATED_DATE - datetime2
          1 , -- CREATED_USER - uniqueidentifier
          GETDATE() , -- UPDATED_DATE - datetime2
          1 , -- UPDATED_USER - uniqueidentifier
          1  -- IS_AVAILABLE_FOR_DROPDOWN - bit

INSERT INTO NFORM.LOOKUP_VALUE
        ( LOOKUP_VALUE_ID ,
          LOOKUP_ID ,
          NAME ,
          DESCRIPTION ,
          CREATED_DATE ,
          CREATED_USER ,
          UPDATED_DATE ,
          UPDATED_USER ,
          IS_ACTIVE
        )
SELECT NEWID() , -- LOOKUP_VALUE_ID - uniqueidentifier
          @LOOKUP_ID , -- LOOKUP_ID - uniqueidentifier
          MySourceTable.Name , -- NAME - nvarchar(600)
          MySourceTable.Description , -- DESCRIPTION - nvarchar(600)
          GETDATE() , -- CREATED_DATE - datetime2
          1 , -- CREATED_USER - uniqueidentifier
          GETDATE() , -- UPDATED_DATE - datetime2
          1 , -- UPDATED_USER - uniqueidentifier
          MySourceTable.IsActive  -- IS_ACTIVE - bit
FROM MySourceTable