/* ************************************************************************* *
 *
 * Datei:       tblDomains.sql
 *
 * Aufgabe:     Tabelle tblDomains anlegen
 *           
 * Aenderungen: 
 *              2021-09-23, MWN, erstellt.
 *
 * ************************************************************************* */

if not exists (select * from sys.tables where object_id = object_id (N'tblDomains')) begin

  -- Protokollausgabe
  print 'Anlegen der Tabelle <' + db_name() + '.dbo.tblDomains>'

  -- drop table tblDomains
  create table tblDomains (

      -- Primaerschluessel
      constraint [PK_tblDomains] primary key ([key])
    ,	[key]					int					identity(1, 1) not null
         
      -- ----------------------------------------------------------------------
      -- Allgemeine Parameter
      -- ----------------------------------------------------------------------
	,	[created]				DateTime			NOT NULL
	,	[lastModified]			DateTime			NOT NULL
                           
      -- ----------------------------------------------------------------------
      -- Parameter
      -- ----------------------------------------------------------------------
    ,	[name]					nvarchar(250)		NOT NULL
	,	[grantedPower]			nvarchar(250)		NOT NULL

  )

  if not exists (select * from sys.tables where object_id = object_id ('tblDomains')) begin
    print ''
    print '************************************'
    print 'Fehler beim Erstellen der Tabelle tblDomains'
    print '************************************'
    print ''
  end

end /*else begin  -- [if not exists (Tabelle)...]

  -- Hinzufuegen einer Spalte
  if not exists (select * from syscolumns where name = 'nSeqDataXLink' and id = object_id('tblDomains') and objectproperty(id, N'IsUserTable') = 1) begin
    print 'alter table tblDomains add nSeqDataXLink bigint null'
    alter table tblDomains add nSeqDataXLink bigint null
  end

end  -- [if not exists (Tabelle)...]*/
go

-- :EOF:
