if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[edk_data]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[edk_data]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[edk_data_doktype]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[edk_data_doktype]
GO

CREATE TABLE [dbo].[edk_data] (
	[RowId] [int] IDENTITY (1, 1) NOT NULL ,
	[TGNummer] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Insert_TimeStamp] [datetime] NULL ,
	[Status] [int] NULL ,
	[Status_TimeStamp] [datetime] NULL ,
	[xmldata] [image] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[edk_data_doktype] (
	[Dokumenttypnr] [int] NOT NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[edk_data] WITH NOCHECK ADD 
	CONSTRAINT [PK_edk_data] PRIMARY KEY  CLUSTERED 
	(
		[RowId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[edk_data_doktype] WITH NOCHECK ADD 
	CONSTRAINT [PK_edk_data_doktype] PRIMARY KEY  CLUSTERED 
	(
		[Dokumenttypnr]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[edk_data] ADD 
	CONSTRAINT [DF_edk_data_Insert_TimeStamp] DEFAULT (getdate()) FOR [Insert_TimeStamp],
	CONSTRAINT [DF_edk_data_Status_TimeStamp] DEFAULT (getdate()) FOR [Status_TimeStamp]
GO

