CREATE PROCEDURE [dbo].[sp_insertTemplateReportScheda]
@nomeTemplate as varchar(50),
@codicePB as varchar(6),
@rete as char,
@idModello as int,
@opznominativa as bit,
@opzterzi as bit
AS
BEGIN
declare @DtCreazione as datetime
SET @DtCreazione = getDate()
DECLARE @Identificativo AS INT
SET NOCOUNT ON;
INSERT INTO [R6_ReportSchede_Template]
           ([codicePB]
           ,[nomeTemplate]
		   ,[default]
		   ,rete
		   ,idModello
		   ,DtCreazione
		   ,opznominativa
		   ,opzterzi)
     VALUES
           (@codicePB,
           @nomeTemplate,
		   'N',
		   @rete,
		   @idModello,
		   @DtCreazione,
		   @opznominativa,
		   @opzterzi)
END
SET @Identificativo = @@identity
SELECT @Identificativo
--	dbo.sp_deleteTemplateReportScheda
/*USE [SEIReport]
GO
ALTER PROCEDURE [dbo].[sp_deleteTemplateReportScheda]
@idTemplate as int
AS
BEGIN
	SET NOCOUNT ON;
BEGIN TRANSACTION
    declare @codicePB as  varchar(6)
    select   @codicePB=dbo.R6_ReportSchede_Template.codicePB FROM dbo.R6_ReportSchede_Template   --figli
		  WHERE R6_ReportSchede_Template.idTemplate = @idTemplate
   if @codicePB <> '' 
   BEGIN  
		DELETE FROM R6_ReportSchede_SchedeTemplate   --figli
			 WHERE R6_ReportSchede_SchedeTemplate.idTemplate = @idTemplate
		DELETE FROM dbo.R6_ReportSchede_Template   --figli
				WHERE R6_ReportSchede_Template.idTemplate = @idTemplate
	END  
COMMIT
END*/