IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_save_extresbase]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_save_extresbase]
GO

-- =============================================
-- Author:<Author,,Name>
-- Create date: <Create Date,,>
-- Description:<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[mps_save_extresbase]
-- Add the parameters for the stored procedure here
@cmpid int,
@etc_id int,
@etc_code varchar(50),
@etc_type nvarchar(100),
@etc_share int,
@etc_keys nvarchar(4000)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

    -- Insert statements for procedure here
UPDATE mps_ext_resource SET 
etc_code =  CASE WHEN @etc_code = '_none_' THEN etc_code ELSE @etc_code END,
etc_type =  CASE WHEN @etc_type = '_none_' THEN etc_type ELSE @etc_type END,
etc_share = CASE WHEN @etc_share = -999999999 THEN etc_share ELSE @etc_share END,
etc_keys = CASE WHEN @etc_keys = '_none_' THEN '' ELSE @etc_keys END
WHERE etc_id = @etc_id AND etc_cmpid = @cmpid
END