IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = 'PISReceivedPrescriptionDetail')
BEGIN
CREATE TABLE [dbo].[PISReceivedPrescriptionDetail](
	[Id] [UNIQUEIDENTIFIER] NOT NULL,
	[PrescriptionId] [UNIQUEIDENTIFIER] NOT NULL,
	[Term] [NVARCHAR](MAX) NULL,
	[ErxCode] [VARCHAR](20) NULL,
	[GoodsCode] [VARCHAR](15) NULL,
	[FrequencyCode] [VARCHAR](20) NULL,
	[RouteCode] [VARCHAR](20) NULL,
	[ShapeCode] [VARCHAR](20) NULL,
	[Description] [NVARCHAR](MAX) NULL,
	[TotalNumber] [MONEY] NULL,
 CONSTRAINT [PK_PISPrescriptionDetail] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)
) ON [PRIMARY] 

ALTER TABLE [dbo].[PISReceivedPrescriptionDetail]  WITH CHECK ADD  CONSTRAINT [FK_PISPrescriptionDetail_PISPrescription] FOREIGN KEY([PrescriptionId])
REFERENCES [dbo].[PISReceivedPrescription] ([Id])
ON DELETE CASCADE
ALTER TABLE [dbo].[PISReceivedPrescriptionDetail] CHECK CONSTRAINT [FK_PISPrescriptionDetail_PISPrescription]
End




