SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MEDWEB_GECMISRECETELER]') AND xtype in (N'FN', N'IF', N'TF'))
DROP FUNCTION [dbo].MEDWEB_GECMISRECETELER
GO

CREATE FUNCTION dbo.MEDWEB_GECMISRECETELER(@HKIMLIKID int,@SUBEID int) 
RETURNS @retGecmisReceteler TABLE 
(
	BOLUMADI nvarchar(100),
	DRADI nvarchar(50),
	RECTARIH datetime
)
AS
BEGIN
	INSERT INTO @retGecmisReceteler
	SELECT BOLUMADI, DRADI, HRECTARIH FROM VWRECETE WHERE HKIMLIKID  = @HKIMLIKID AND SUBEID = @SUBEID
    RETURN
END
GO