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

CREATE PROCEDURE [dbo].[SPWEB_BOLUMLER]
AS
BEGIN
	--EXEC SPWEB_LOGLA 'subeler',@kisino,'Şube listesini çekti',''
	SELECT	TBOLUM.BOLUMID AS bolumid, TBOLUM.BOLUMADI as bolum 
	FROM	TBOLUM WITH(NOLOCK)
	WHERE TBOLUM.BOLUMID IN (SELECT SUBEBOLUM.BOLUMID FROM SUBEBOLUM WITH(NOLOCK) WHERE WEBRANDEVUVERILIR=1 )
	ORDER BY TBOLUM.BOLUMADI
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_BOLUMLER] TO [mediwebuser]
	END TRY
	BEGIN CATCH
	END CATCH
END
GO




