Print ''
Print '-------------------------------------------------------------------------'
Print ' using Database: #DB_N#'
Print ' Table         : [ReportPageNames_temp_tbl]'
Print ' Creation Date : 18.10.2010'
Print ' Autor         : A.Becker'
Print ' '
Print '-------------------------------------------------------------------------'

use [#DB_N#]


Declare @MyActionMsg1 nvarchar (max)
Declare @MyTableName nvarchar (max)
set @MyTableName='ReportPageNames_temp_tbl'

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

--------------------------------------------------------------------------------
TableCreate:
  set @MyActionMsg1=
      '-- Table: [ReportPageNames_temp_tbl] dose not exist and will be created new'
  Print (@MyActionMsg1)
CREATE TABLE [dbo].[ReportPageNames_temp_tbl] (
      [Position]     int ,                               -- Gibt die Sortierung des Repoart an (nur SQL-Server intererne verwendung)
      [Name]         [nvarchar] (100) ,                  -- Name des Reports erscheint in den Register Karten 
      [Description]  [nvarchar] (max)                    -- Beschreibung des Reports ist im LundL Report verfügbar 
)
ON [PRIMARY]
  goto CheckCreateIndex

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

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

  Declare @ColumeName nvarchar (256)
  Declare @ColumeNameOld nvarchar (256)
  Declare @ColumeNameNew nvarchar (256)
  Declare @ExecuteStr nvarchar (max)

goto CheckCreateIndex

CheckCreateIndex:


--------------------------------------------------------------------------------
EndeExit:
 Print '------------------------------------------------------------------------'
 Print (@MyActionMsg1)
 Print ('   |-> Done on Database: #DB_N#')
 Print '------------------------------------------------------------------------'

GO
