IF NOT EXISTS (SELECT * FROM SYSOBJECTS
              WHERE  SYSOBJECTS.name = 'TDRCALSAATDETAYLI')

CREATE TABLE [dbo].[TDRCALSAATDETAYLI](
	[TDRCALSAATDETAYID] [int] IDENTITY(1,1) NOT NULL,
	[DRID] [int] NOT NULL,
	[TARIH] [datetime] NOT NULL,
	[SBASSAAT] [datetime] NOT NULL,
	[SBITSAAT] [datetime] NOT NULL,
	[OSBASSAAT] [datetime] NOT NULL,
	[OSBITSAAT] [datetime] NOT NULL,
	[CALISMASAATI] [float] NOT NULL,
 CONSTRAINT [PK_TDRCALSAATDETAYLI] PRIMARY KEY CLUSTERED 
(
	[TDRCALSAATDETAYID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO


IF NOT EXISTS (SELECT * FROM SYSOBJECTS
              WHERE  SYSOBJECTS.name = 'DF_TDRCALSAATDETAYLI_CALISMASAATI')
ALTER TABLE [dbo].[TDRCALSAATDETAYLI] ADD  CONSTRAINT [DF_TDRCALSAATDETAYLI_CALISMASAATI]  DEFAULT ((8)) FOR [CALISMASAATI]
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TDRCALSAATDETAYLI]') AND 
name = N'IX_TDRCALSAATDETAYLI_DRID_TARIH')

CREATE UNIQUE NONCLUSTERED INDEX [IX_TDRCALSAATDETAYLI_DRID_TARIH] ON [dbo].[TDRCALSAATDETAYLI]
(
	[DRID] ASC,
	[TARIH] DESC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
GO




