if NOT exists (select * from sysobjects where name = N'Tbl_RandomLottery')
Begin
CREATE TABLE [dbo].[Tbl_RandomLottery](
	[AutoId] [int] IDENTITY(1,1) NOT NULL,
	[Id_Havaleh] [bigint] NULL,
	[A_Code] [varchar](3) NULL,
	[K_code] [varchar](20) NOT NULL,
	[Qty] [money] NOT NULL,
	[Family] [nvarchar](50) NULL,
	[Mobile] [char](11) NULL,
	[StartDate] [smalldatetime] NOT NULL,
	[EndDate] [smalldatetime] NOT NULL,
	[Note] [nvarchar](50) NULL,
	[Tarikh] [smalldatetime] NULL,
	[MinFactor] [money] NULL,
	[Flag] [char](1) NULL,
	[CashNumber] [tinyint] NULL,
	[TotPrice] [money] NULL,
	[Page] [bit] NULL,
        [SystemName] [VARCHAR](300) NULL,
 CONSTRAINT [PK_Tbl_RandomLottery] PRIMARY KEY CLUSTERED 
(
	[AutoId] ASC
)
) ON [PRIMARY]

ALTER TABLE [dbo].[Tbl_RandomLottery] ADD  CONSTRAINT [DF_Tbl_RandomLottery_Qty]  DEFAULT ((1)) FOR [Qty]
ALTER TABLE [dbo].[Tbl_RandomLottery] ADD  CONSTRAINT [DF_Tbl_RandomLottery_StartDate]  DEFAULT (getdate()) FOR [StartDate]
ALTER TABLE [dbo].[Tbl_RandomLottery] ADD  CONSTRAINT [DF_Tbl_RandomLottery_EndDate]  DEFAULT (getdate()) FOR [EndDate]
ALTER TABLE [dbo].[Tbl_RandomLottery] ADD  CONSTRAINT [DF_Tbl_RandomLottery_Tarikh]  DEFAULT (getdate()) FOR [Tarikh]
ALTER TABLE [dbo].[Tbl_RandomLottery] ADD  CONSTRAINT [DF_Tbl_RandomLottery_TotPrice]  DEFAULT ((0)) FOR [TotPrice]
ALTER TABLE [dbo].[Tbl_RandomLottery] ADD  CONSTRAINT [DF_Tbl_RandomLottery_Page]  DEFAULT ((0)) FOR [Page]
End

