create table ElencoPostazioni(
  codPostazione nvarchar(250) not null constraint PK_ElencoPostazioni primary key,
  stampante     nvarchar(250)
);
go

set xact_abort on
go

begin transaction
go

INSERT INTO dbo.ElencoPostazioni
  VALUES (N'default', N'null')
INSERT INTO dbo.ElencoPostazioni
  VALUES (N'VOSTRO410', N'//vostro410/PdfCreator')
go

commit transaction
go


set xact_abort on
go

begin transaction
go

INSERT INTO dbo.AnagStatiProdotto
  VALUES (N'Wip', N'Materiale in WIP')
go

commit transaction
go

set xact_abort on;
go

begin transaction;
go

set ANSI_NULLS on;
go

/***************************************
* STORED stp_elencoPostaziont_getByCod
*
* ottiene il una postazione dato il codice
*
* Steamware, S.E.L.
* mod: 2010.11.17
*
****************************************/
create PROCEDURE stp_elencoPostaziont_getByCod
(
	@codPostazione NVARCHAR(250)
)
AS

SELECT      *
FROM        ElencoPostazioni
WHERE       codPostazione = @codPostazione

RETURN
go

commit;
go

set xact_abort on;
go

begin transaction;
go

set ANSI_NULLS on;
go

/***************************************
* STORED stp_UDC_getLast_ByParticolare
*
* elenco cartellini ULTIMO creati x particolare
*
* Steamware, S.E.L.
* mod: 2011.11.14
*
****************************************/
create PROCEDURE stp_UDC_getLast_ByParticolare
(
	@CodCS VARCHAR(2),
	@Particolare VARCHAR(15)
)
AS

	-- prendo ultimo UDC creato x il particolare
	SELECT		TOP 1 * FROM ElencoCartellini 
	WHERE		(Particolare= @Particolare) AND CodCS = @CodCS
	ORDER BY	CreateDate DESC

RETURN
go

commit;
go


set xact_abort on
go

begin transaction
go

INSERT INTO dbo.AnagPosizioni
  VALUES (-5, N'SP - WIP consumati', 0)
INSERT INTO dbo.AnagPosizioni
  VALUES (5, N'SP - WIP', 0)
go

commit transaction
go


set xact_abort on
go

begin transaction
go

INSERT INTO dbo.TabTranPosizEventi
  VALUES (N'UDC_CONS', 5, -5, 0)
go

commit transaction
go



set xact_abort on
go

begin transaction
go

INSERT INTO dbo.AS400_MagCont
  VALUES (N'4', N'Finiti', 1, N'0')
INSERT INTO dbo.AS400_MagCont
  VALUES (N'5', N'WIP', 1, N'0')
INSERT INTO dbo.AS400_MagCont
  VALUES (N'6', N'MP', 1, N'0')
DELETE FROM dbo.AS400_MagCont WHERE CodMagAS=N'54'
go

commit transaction
go







-- registro versione...
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(400, GETDATE())
GO
