IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_messagetemplate_selectableapp]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_messagetemplate_selectableapp]
GO
CREATE proc [dbo].[mps_gen_messagetemplate_selectableapp]
@cmpid int,
@type varchar(10)
as
begin
set nocount on
declare @data varchar(max)
set @data='';
select @data+=wx_title+'='+CONVERT(varchar,wx_id)+'|' from ebs_kernel.dbo.pub_weixin where wx_cmpid=@cmpid and wx_type=@type
if LEN(@data)>1
select SUBSTRING(@data,1,LEN(@data)-1) apps;
else
select @data apps;
set nocount off
end