
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[FNMED_TABLETICERIK]') AND xtype in (N'FN', N'IF', N'TF'))
	DROP FUNCTION [dbo].[FNMED_TABLETICERIK]
GO
CREATE FUNCTION [dbo].[FNMED_TABLETICERIK](@SUBEID INT,@TABLETIP NVARCHAR(15))
RETURNS @TABLETICERIK TABLE 
(
	SUBEID INT NOT NULL,
	TABLETIP NVARCHAR(15) NOT NULL,
	ICERIK NVARCHAR(15) NULL,
	MEDISOFTPCNAME NVARCHAR(20) NULL,
	YATISODANO INT,	
	SIRADRID INT NULL,
	SIRABOLUMID INT NULL,
	SIRABIRIMID INT NULL

) 
AS
BEGIN

  INSERT INTO @TABLETICERIK (SUBEID, TABLETIP, ICERIK, MEDISOFTPCNAME, YATISODANO, SIRADRID, SIRABOLUMID,SIRABIRIMID)
  SELECT SUBEID, TABLETIP, ICERIK, MEDISOFTPCNAME, YATISODANO, SIRADRID, SIRABOLUMID,SIRABIRIMID  FROM TTABLET WHERE TABLETIP=@TABLETIP AND SUBEID=@SUBEID
   RETURN 
END
GO