SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

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

CREATE FUNCTION dbo.MEDWEB_GECMISTETKIKTEST(@TETKIKID int) 
RETURNS @retGecmisTetkikTest TABLE 
(
	ISLEMADI nvarchar(150),
	TESTADI nvarchar(150),
	OLCUM nvarchar(50),
	SONUCR float,
	BIRIM nvarchar(50),
	SONUCY nvarchar(150),
	MIND float,
	MIND2 float,
	MAXD float,
	MAXD2 float
)
AS
BEGIN
	INSERT INTO @retGecmisTetkikTest
	SELECT ITEMADI, TESTADI, OLCUM, SONUCR, BIRIM, SONUCY, MIND,MIND2, MAXD, MAXD2
	FROM VWTETKIKTEST WHERE HTETKIKID  = @TETKIKID AND RAPORDAGORUNSUN = 1
    RETURN
END
GO
