IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[SPWEB_DOKTOROZGECMIS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE SPWEB_DOKTOROZGECMIS
GO

CREATE PROCEDURE [dbo].[SPWEB_DOKTOROZGECMIS]
@doktorno INT
AS
BEGIN


	SELECT TDROZGECMISTUR.BASLIK AS tur, HTMLICERIK AS icerik
	FROM TDROZGECMIS WITH(NOLOCK)
	JOIN TDROZGECMISTUR WITH(NOLOCK) ON TDROZGECMISTUR.TUR=TDROZGECMIS.TUR
	WHERE	DRID=@doktorno
	ORDER BY TDROZGECMISTUR.SIRA, TDROZGECMIS.SIRA, TDROZGECMIS.DROZGECMISID
						
END
GO

IF EXISTS (SELECT [name] FROM [sys].[database_principals] WHERE [type] = N'S' AND [name] = N'mediwebuser')
BEGIN
	BEGIN TRY
		GRANT EXECUTE ON [dbo].[SPWEB_DOKTOROZGECMIS] TO [mediwebuser]
	END TRY
	BEGIN CATCH
	END CATCH
END
GO


