33 lines
1.1 KiB
Transact-SQL
33 lines
1.1 KiB
Transact-SQL
CREATE PROCEDURE [dbo].[R6_S_QuerySezioni]
|
|
@idReport as int,
|
|
@idModello as int
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON;
|
|
declare @idFkTipoCheck as int
|
|
set @idFkTipoCheck = 1
|
|
SELECT queryOracleSezione, ordineQueryOracleSezione
|
|
from (
|
|
SELECT
|
|
isnull([R6Sezione].[queryOracle],'') as queryOracleSezione
|
|
,isnull([R6Sezione].[ordineQueryOracle],-1) as ordineQueryOracleSezione
|
|
FROM dbo.R6Sezione
|
|
INNER JOIN dbo.R6_SezioneR6Sezione
|
|
ON dbo.R6_SezioneR6Sezione.idFkC6Sezione = dbo.R6Sezione.id
|
|
AND dbo.R6Sezione.queryOracle IS NOT NULL
|
|
INNER JOIN dbo.Sezione
|
|
ON dbo.R6_SezioneR6Sezione.idFkSezione = dbo.Sezione.IdSezione
|
|
and dbo.Sezione.idFkTipoCheck = @idFkTipoCheck
|
|
INNER JOIN dbo.ReportSezionePers
|
|
ON dbo.ReportSezionePers.IdSezione = dbo.Sezione.IdSezione
|
|
AND dbo.ReportSezionePers.idReport = @idModello
|
|
UNION ALL
|
|
SELECT
|
|
isnull(C6SezioneDatiComuni.queryOracle,'') as queryOracleSezione
|
|
,isnull(C6SezioneDatiComuni.ordineQuery,-1) as ordineQueryOracleSezione
|
|
from C6SezioneDatiComuni
|
|
where idReport = @idReport or isnull(idReport,0) = 0
|
|
) A
|
|
group by A.queryOracleSezione,A.ordineQueryOracleSezione
|
|
order by A.ordineQueryOracleSezione desc
|
|
END |