IF NOT EXISTS(SELECT * FROM sys.sysobjects WHERE name ='UserShiftWork' and xtype='U')
Begin
CREATE TABLE [dbo].[UserShiftWork](
	[Id] [UNIQUEIDENTIFIER] NOT NULL,
	[UserId] [UNIQUEIDENTIFIER] NOT NULL,
	[DocumentDate] [SMALLDATETIME] NOT NULL,
	[Status] [BIT] NOT NULL,
 CONSTRAINT [PK_UserShiftWork] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)
) ON [PRIMARY]

ALTER TABLE [dbo].[UserShiftWork] ADD  CONSTRAINT [DF_UserShiftWork_Id]  DEFAULT (NEWID()) FOR [Id]

ALTER TABLE [dbo].[UserShiftWork] ADD  CONSTRAINT [DF_UserShiftWork_Status]  DEFAULT ((0)) FOR [Status]

ALTER TABLE [dbo].[UserShiftWork]  WITH CHECK ADD  CONSTRAINT [FK_UserShiftWork_UserAccountingCode] FOREIGN KEY([UserId])
REFERENCES [dbo].[UserAccountingCode] ([Id])

ALTER TABLE [dbo].[UserShiftWork] CHECK CONSTRAINT [FK_UserShiftWork_UserAccountingCode]

END