﻿CREATE  PROCEDURE [dbo].[sp_getAllSchedeByIdTemplate]
@IdTemplate as int,
@Default as char
AS
BEGIN
if @Default =  'N' 
BEGIN
	SELECT  S.idScheda, S.nomeImmagineScheda, S.testoHTML, S.numTab, S.sezioni,S.vincoli
	FROM R6_ReportSchede_Schede S INNER JOIN
		R6_ReportSchede_SchedeTemplate T 
	ON S.idScheda = T.idSchede
	WHERE T.idTemplate = @IdTemplate
	order by ordine
END
if @Default =  'S' 
BEGIN
	SELECT   S.idScheda, S.nomeImmagineScheda, S.testoHTML, S.numTab, S.sezioni,S.vincoli
	FROM R6_ReportSchede_Schede S INNER JOIN
		R6_ReportSchede_SchedeTemplateDefault T
		ON S.idScheda = T.idSchede
	WHERE T.idTemplate = @IdTemplate
	order by ordine
END
END