IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_report_display]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_report_display]
GO
-- =============================================
-- Author:flobit
-- Create date: 2018年1月30日
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[mps_g_report_display]
@rpt_id int,
@ismobie int = 1
AS
BEGIN
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
--1.获取模板  
if not @ismobie = 0
begin
select case when DATALENGTH(tmp_formmobile)>0 then  tmp_formmobile else tmp_form end as tmp_form,
case when DATALENGTH(tmp_jsmobile)>0 then  tmp_jsmobile else tmp_js end as tmp_js,
case when DATALENGTH(tmp_cssmobile)>0 then  tmp_cssmobile else tmp_css end  as tmp_css
from mps_template where tmp_objid=@rpt_id and tmp_type='report'
end else begin
select tmp_form,tmp_js,tmp_css from mps_template where tmp_objid=@rpt_id and tmp_type='report'
end
--2.执行SQL
declare @sql nvarchar(2000)
set @sql = ''
select @sql=rpt_sql from mps_report where rpt_id = @rpt_id
exec sp_executesql @sql
END

drop PROCEDURE  mps_save_document