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

-- =============================================
-- Author:<Author,,Name>
-- Create date: <Create Date,,>
-- Description:<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[mps_save_equctgbase]
-- Add the parameters for the stored procedure here
@cmpid int,
@ec_id int,
@ec_bmcodevarchar(200),
@ec_typenvarchar(100),
@ec_iconvarchar(200),
@ec_shareint,
@ec_keysnvarchar(4000),
@ec_databasevarchar(50),
@ec_groupfieldsnvarchar(200),
@ec_securityint,
@ec_orderint,
@ec_querytimeint,
@ec_fullnvarchar(500),
@ec_searchfieldsvarchar(2000),
@ec_selectfuncsnvarchar(500),
@ec_selectstyleint,
@ec_funcsvarchar(200),
@ec_flowsnvarchar(2000),
@ec_paramsvarchar(500),
@ec_viewscopeint,
@ec_viewsint,
@ec_selectnvarchar(4000),
@ec_fromnvarchar(2000),
@ec_wherenvarchar(4000),
@ec_orderbynvarchar(2000) 
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_equctg SET 
ec_bmcode =  CASE WHEN @ec_bmcode = '_none_' THEN ec_bmcode ELSE @ec_bmcode END,
ec_type =  CASE WHEN @ec_type = '_none_' THEN ec_type ELSE @ec_type END,
ec_icon =  CASE WHEN @ec_icon = '_none_' THEN ec_icon ELSE @ec_icon END,
ec_share = CASE WHEN @ec_share = -999999999 THEN ec_share ELSE @ec_share END,
ec_keys = CASE WHEN @ec_keys = '_none_' THEN '' ELSE @ec_keys END,
ec_database=  CASE WHEN @ec_database = '_none_' THEN ec_database ELSE @ec_database END,
ec_groupfields=  CASE WHEN @ec_groupfields = '_none_' THEN ec_groupfields ELSE @ec_groupfields END,
ec_security= CASE WHEN @ec_security = -999999999 THEN ec_security ELSE ec_security END,
ec_order= CASE WHEN @ec_order = -999999999 THEN ec_order ELSE @ec_order END,
ec_querytime= CASE WHEN @ec_querytime = -999999999 THEN ec_querytime ELSE ec_querytime END,
ec_full=  CASE WHEN @ec_full = '_none_' THEN ec_full ELSE @ec_full END,
ec_searchfields=  CASE WHEN @ec_searchfields = '_none_' THEN ec_searchfields ELSE @ec_searchfields END,
ec_selectfuncs=  CASE WHEN @ec_selectfuncs = '_none_' THEN ec_selectfuncs ELSE @ec_selectfuncs END,
ec_selectstyle= CASE WHEN @ec_selectstyle = -999999999 THEN ec_selectstyle ELSE @ec_selectstyle END,
ec_funcs=  CASE WHEN @ec_funcs = '_none_' THEN ec_funcs ELSE @ec_funcs END,
ec_flows=  CASE WHEN @ec_flows = '_none_' THEN ec_flows ELSE @ec_flows END,
ec_params=  CASE WHEN @ec_params = '_none_' THEN ec_params ELSE @ec_params END,
ec_viewscope= CASE WHEN @ec_viewscope = -999999999 THEN ec_viewscope ELSE @ec_viewscope END,
ec_views= CASE WHEN @ec_views = -999999999 THEN ec_views ELSE @ec_views END,
ec_select=  CASE WHEN @ec_select = '_none_' THEN ec_select ELSE @ec_select END,
ec_from=  CASE WHEN @ec_from = '_none_' THEN ec_from ELSE @ec_from END,
ec_where=  CASE WHEN @ec_where = '_none_' THEN ec_where ELSE @ec_where END,
ec_orderby=  CASE WHEN @ec_orderby = '_none_' THEN ec_orderby ELSE @ec_orderby END
WHERE ec_id = @ec_id AND ec_cmpid = @cmpid
END