Declare @Id Int                               
Select @Id = Id From sysobjects Where Name = 'Tbl_RandomLottery'
if not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'LotteryType')
  Alter Table dbo.Tbl_RandomLottery Add LotteryType tinyint Default(0)

Select @Id = Id From sysobjects Where Name = 'Tbl_RandomLottery'
if not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'StartFactorNumber')
  Alter Table dbo.Tbl_RandomLottery Add StartFactorNumber int Default(0)

Select @Id = Id From sysobjects Where Name = 'Tbl_RandomLottery'
if not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'EndFactorNumber')
  Alter Table dbo.Tbl_RandomLottery Add EndFactorNumber int Default(0)
