IF Not (EXISTS(SELECT * FROM sysobjects WHERE name='TaminSavedPrescriptionDetail'))
Begin
CREATE TABLE [dbo].[TaminSavedPrescriptionDetail](
	[Id] [UNIQUEIDENTIFIER] NOT NULL,
	[PrescriptionId] [UNIQUEIDENTIFIER] NULL,
	[GenericCode] [VARCHAR](5) NULL,
	[GoodsCode] [VARCHAR](15) NULL,
	[OrderCount] [INT] NULL,
	[InsuranceStatus] [BIT] NULL,
	[Instruction] [NVARCHAR](MAX) NULL,
 CONSTRAINT [PK_TaminPaperPrescriptionDetail] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)
) ON [PRIMARY] 

ALTER TABLE [dbo].[TaminSavedPrescriptionDetail] ADD  CONSTRAINT [DFTaminSavedPrescriptionDetail_id]  DEFAULT (NEWID()) FOR [Id]
  ALTER TABLE dbo.TaminSavedPrescriptionDetail ADD CONSTRAINT FK_TaminSavedPrescriptionDetail_TaminSavedPrescription
    FOREIGN KEY (PrescriptionId) REFERENCES dbo.TaminSavedPrescription (Id) ON DELETE CASCADE;
ALTER TABLE [dbo].[TaminSavedPrescriptionDetail] CHECK CONSTRAINT [FK_TaminSavedPrescriptionDetail_TaminSavedPrescription]
End
