DECLARE @Id Int                               
Select @Id = Id From sysobjects Where Name = 'IHIOPrescriptionDetail'
IF not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'NumberOfPeriodCode')
  Alter Table IHIOPrescriptionDetail Add NumberOfPeriodCode VARCHAR(20);

DECLARE @ConstraintName VARCHAR(MAX)
SELECT @ConstraintName = (SELECT name FROM sysobjects  WHERE name like 'DF__IHIOPresc__Numbe%')
IF @ConstraintName IS NOT NULL
BEGIN 
  SET @ConstraintName = 'ALTER TABLE IHIOPrescriptionDetail DROP CONSTRAINT ' + @ConstraintName 
  EXEC(@ConstraintName)
  ALTER TABLE IHIOPrescriptionDetail ALTER COLUMN NumberOfPeriod FLOAT 
  ALTER TABLE dbo.IHIOPrescriptionDetail ADD CONSTRAINT DF_IHIOPresc_NumberOfPeriod DEFAULT(0) FOR NumberOfPeriod
END 