DECLARE @Id Int                               

SELECT @Id = Id From sysobjects Where Name = 'TmpDrugh'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'Id')
  Alter Table TmpDrugh Add Id UNIQUEIDENTIFIER NOT NULL DEFAULT(NEWID())


SELECT @Id = Id From sysobjects Where Name = 'Drugh'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'Id')
  Alter Table Drugh Add Id UNIQUEIDENTIFIER NOT NULL  DEFAULT(NEWID())


SELECT @Id = Id From sysobjects Where Name = 'TmpDrughavaleh'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'FrequencyCode')
  Alter Table TmpDrughavaleh Add FrequencyCode VARCHAR(9)


SELECT @Id = Id From sysobjects Where Name = 'TmpDrughavaleh'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'RouteCode')
  Alter Table TmpDrughavaleh Add RouteCode VARCHAR(9)


SELECT @Id = Id From sysobjects Where Name = 'TmpDrughavaleh'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'Note')
  Alter Table TmpDrughavaleh Add Note NVARCHAR(max)


SELECT @Id = Id From sysobjects Where Name = 'Drughavaleh'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'FrequencyCode')
  Alter Table Drughavaleh Add FrequencyCode VARCHAR(9)


SELECT @Id = Id From sysobjects Where Name = 'Drughavaleh'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'RouteCode')
  Alter Table Drughavaleh Add RouteCode VARCHAR(9)


SELECT @Id = Id From sysobjects Where Name = 'Drughavaleh'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'Note')
  Alter Table Drughavaleh Add Note NVARCHAR(max)

SELECT @Id = Id From sysobjects Where Name = 'Kalaid'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'ErxCode')
  Alter Table Kalaid Add ErxCode VARCHAR(10) NULL

Select @Id = Id From sysobjects Where Name = 'Kalaid'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'ShapeCode')
  Alter Table Kalaid Add ShapeCode VARCHAR(6) NULL

Select @Id = Id From sysobjects Where Name = 'Kalaid'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'NationalId')
  Alter Table Kalaid Add NationalId VARCHAR(15) NULL  

SELECT @Id = Id From sysobjects Where Name = 'TblUseMind'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'RouteCode')
  Alter Table TblUseMind Add RouteCode VARCHAR(9) NULL  
  

SELECT @Id = Id From sysobjects Where Name = 'TblUseMind'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'FrequencyCode')
  Alter Table TblUseMind Add FrequencyCode VARCHAR(9) NULL  


