IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_save_branch]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_save_branch]
GO
CREATE procedure [dbo].[mps_save_branch]
-- Add the parameters for the stored procedure here
@cmpid int,
@bc_id int,
@bc_order int,
@bc_code varchar(30),
@bc_company nvarchar(100) 
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
UPDATE mps_branch SET 
bc_code =  CASE WHEN @bc_code = '_none_' THEN bc_code ELSE @bc_code END,
bc_order =  CASE WHEN @bc_order = -999999999 THEN bc_order ELSE @bc_order END,
bc_company =  CASE WHEN @bc_company = '_none_' THEN bc_company ELSE @bc_company END
WHERE bc_id = @bc_id AND bc_cmpid = @cmpid
EXEC mps_update_branchinfo @cmpid
END