Print ''
Print '-------------------------------------------------------------------------'
Print ' using Database: #DB_N#'
Print ' Table         : [ObjectsProcessDataErrorsGroupedByResMsg_tbl]'
Print ' Creation Date : 12.06.2019'
Print ' Autor         : S.Gueth'
Print ' '
Print '-------------------------------------------------------------------------'

use [#DB_N#]


Declare @MyActionMsg1 nvarchar (max)
Declare @MyTableName nvarchar (max)
DECLARE @ExecuteSQLstr nvarchar(max)

set @MyTableName='ObjectsProcessDataErrorsGroupedByResMsg_tbl'

declare @indexNrStr   nvarchar (max)
declare @IndexName    nvarchar (max)

declare @ColumeName nvarchar (max)
declare @ColumeNameOld nvarchar (max)
declare @ColumeNameNew nvarchar (max)
declare @ExecuteStr nvarchar (max)

--------------------------------------------------------------------------------
-- verzweigen auf TableCreate: oder TableUpdate:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ObjectsProcessDataErrorsGroupedByResMsg_tbl]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  BEGIN
   goto TableUpdate
  END
ELSE
  BEGIN
   goto TableCreate
  END

--------------------------------------------------------------------------------
TableCreate:
  set @MyActionMsg1=
      '-- Table: [ObjectsProcessDataErrorsGroupedByResMsg_tbl] dose not exist and will be created new'
  Print (@MyActionMsg1)

  CREATE TABLE [dbo].[ObjectsProcessDataErrorsGroupedByResMsg_tbl] (
    [Id]                         [uniqueidentifier] NOT NULL DEFAULT NEWSEQUENTIALID(),
    [ObjectClass]                nvarchar(10)   ,
    [ObjectFromSiteID]           nvarchar(32)   ,
    [ProcessProcStateCol]        nvarchar (32)  ,
    [ProcessResultKey]           nvarchar (32)  , 
    [ProcessResultMsg]           nvarchar (450) ,
    [ProcessCount]               int
  )
  ON [PRIMARY]
  
  Goto CheckCreateIndex


--------------------------------------------------------------------------------
TableUpdate:

  set @MyActionMsg1=
       '-- Table: [ObjectsProcessDataErrorsGroupedByResMsg_tbl] exist and will be updated'
  Print (@MyActionMsg1)

 
 
 

  goto CheckCreateIndex

--------------------------------------------------------------------------------
CheckCreateIndex:

   

EndeExit:
 Print '------------------------------------------------------------------------'
 Print 'Done on Database: #DB_N#'
 Print '------------------------------------------------------------------------'
GO
