/****** Object:  Trigger [TRG_EST_TRIB_NAO_ALTERAR]    Script Date: 04/02/2015 14:44:49 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRG_EST_TRIB_NAO_ALTERAR]'))
DROP TRIGGER [dbo].[TRG_EST_TRIB_NAO_ALTERAR]
GO
GO
GO
--vERSAO 2886
--------------------------------------Tratamento para nao alteracao do consumidor final--------------------------------------
create TRIGGER [dbo].[TRG_EST_TRIB_NAO_ALTERAR] ON [dbo].[EST_TRIB] FOR UPDATE AS
	  begin
		if NOT EXISTS(SELECT
						CD_USU
					  FROM
						EST_TRIB
					  WHERE
						CD_USU =1
						)
		begin
			RAISERROR ('Alteracao de tributacao nao permitida.',16, 1);
			ROLLBACK TRANSACTION;
			RETURN;
	   end
	END
