IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_weixin_selectableapp]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_weixin_selectableapp]
GO
CREATE proc [dbo].[mps_gen_weixin_selectableapp]
@cmpid int,
@type varchar(10)
as
begin
set nocount on
declare @data varchar(max)
set @data='';
if (@type='all')
select @data+=wx_title+'='+wx_code+'_'+CONVERT(varchar,wx_appid)+'|' from ebs_kernel.dbo.pub_weixin where wx_cmpid=@cmpid and (wx_type='DING' or wx_type='QYH' or wx_type='GZH')
else
select @data+=wx_title+'='+wx_code+'_'+CONVERT(varchar,wx_appid)+'|' 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