/* versione 160 */

set xact_abort on
go

begin transaction
go

alter table ElencoListePrelievo add
  Destinatario nvarchar(50)
go

create index i_destinatario on ElencoListePrelievo(Destinatario)
go

set ANSI_NULLS on
go

/***************************************
* STORED stp_creaListaPrelievo
*
* crea un nuovo record nella ElencoListePrelievo e restituisce il codice ID appena creato
*
* Steamware, S.E.L. 8 (FROM Stintino)
* mod: 2010.07.30
*
************************************/
alter PROCEDURE stp_creaListaPrelievo
(
	@Anno NVARCHAR(2),
	@Mese NVARCHAR(2),
	@CodTipoLista NVARCHAR(10),
	@CodCS NCHAR(2),
	@CodCliente NVARCHAR(6),
	@RagSociale NVARCHAR(35),
	@CodSoggetto NCHAR(16),
	@Particolare NVARCHAR(15),
	@DescParticolare NVARCHAR(30),
	@DisegnoGrezzo NVARCHAR(30),
	@Esponente NVARCHAR(6),
	@Figura NVARCHAR(4),
	@CodImballo NVARCHAR(15),
	@QtaTot DECIMAL(10,2),
	@Destinatario NVARCHAR(50)
)
AS

-- Dichiarazioni iniziali
DECLARE @CodLista AS NVARCHAR(12)
DECLARE @numLista AS INT
DECLARE @temp AS INT
DECLARE @ora AS DATETIME
	
------------------------------------------------------------------------------------------------------
-- codice lista di prelievo KAAMM00000 - K = start char, AA = anno, MM = mese, 00000 = progressivo
------------------------------------------------------------------------------------------------------
-- controllo se ci sia già una lista di prelievo per company / flusso anno
BEGIN TRAN
	-- cerco nella tab contatori liste prelievo l'ultimo valido
	SET @numLista = (
		SELECT COUNT(*)
		FROM ContatoriListePrelievo
		WHERE	CodCS		=	@CodCS
		AND		Anno		=	@Anno
		AND		Mese		=	@Mese
	)
	-- controllo se record c'è...
	IF(@numLista > 0)
		BEGIN
			-- se c'è incremento di 1 in tab
			UPDATE ContatoriListePrelievo
			SET LastIdx = LastIdx  + 1
			WHERE	CodCS		=	@CodCS
			AND		Anno		=	@Anno
			AND		Mese		=	@Mese

		END
	ELSE
		BEGIN
			-- lo creo!
			INSERT INTO ContatoriListePrelievo(CodCS, Anno, Mese, LastIdx)
			VALUES (@CodCS, @Anno, @Mese, 1)
		END		
	-- aggiorno numero lista prelievo
	SET @numLista = (
		SELECT LastIdx
		FROM ContatoriListePrelievo
		WHERE	CodCS		=	@CodCS
		AND		Anno		=	@Anno
		AND		Mese		=	@Mese

	)
COMMIT TRAN
------------------------------------------------------------------------------------------------------

BEGIN TRAN

	------------------------------------------------------------------------------------------------------
	-- Ciclo principale x inserimento nuovo record	
	------------------------------------------------------------------------------------------------------
	-- ottengo il nuovo codice lista di prelievo completo
	SET @CodLista = 'K' + @CodCS + @Anno + dbo.f_padLeft(CAST(@Mese AS NVARCHAR(2)), 2, '0') + + dbo.f_padLeft(CAST(@numLista AS NVARCHAR(5)), 5, '0')

	INSERT INTO ElencoListePrelievo
						  (CodLista, CodTipoLista, CodCS, DataCreaz, CodCliente, RagSociale, CodSoggetto, Particolare, DescParticolare, DisegnoGrezzo, Esponente, Figura, CodImballo, QtaTot, CodStatoLista, Destinatario)
	VALUES     (@CodLista, @CodTipoLista, @CodCS, GETDATE(), @CodCliente, @RagSociale, @CodSoggetto, @Particolare, @DescParticolare, @DisegnoGrezzo, @Esponente,@Figura, @CodImballo, @QtaTot, 0, @Destinatario)

COMMIT TRAN

SELECT * FROM V_elencoListePrelievo WHERE CodLista = @CodLista;

RETURN
go

create VIEW v_selDestinatariListePrelievo
AS
SELECT DISTINCT ISNULL(Destinatario, '') AS Destinatario
FROM            dbo.ElencoListePrelievo
go

exec sp_addextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "ElencoListePrelievo"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 315
               Right = 208
            End
            DisplayFlags = 280
            TopColumn = 2
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 9
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'SCHEMA', 'dbo', 'VIEW', 'v_selDestinatariListePrelievo'
go

exec sp_addextendedproperty 'MS_DiagramPaneCount', 1, 'SCHEMA', 'dbo', 'VIEW', 'v_selDestinatariListePrelievo'
go

alter VIEW V_elencoListePrelievo
AS
SELECT        TOP (100) PERCENT dbo.ElencoListePrelievo.CodLista, dbo.ElencoListePrelievo.CodTipoLista, dbo.ElencoListePrelievo.CodCS, dbo.ElencoListePrelievo.DataCreaz, 
                         dbo.ElencoListePrelievo.CodCliente, dbo.ElencoListePrelievo.RagSociale, dbo.ElencoListePrelievo.CodSoggetto, dbo.ElencoListePrelievo.Particolare, 
                         dbo.ElencoListePrelievo.DescParticolare, dbo.ElencoListePrelievo.DisegnoGrezzo, dbo.ElencoListePrelievo.Esponente, dbo.ElencoListePrelievo.Figura, 
                         dbo.ElencoListePrelievo.CodImballo, dbo.ElencoListePrelievo.QtaTot, dbo.ElencoListePrelievo.CodStatoLista, ISNULL(dbo.v_righePrelevate.TotQta, 0) AS Prelevato, 
                         dbo.ElencoListePrelievo.Destinatario
FROM            dbo.ElencoListePrelievo LEFT OUTER JOIN
                         dbo.v_righePrelevate ON dbo.ElencoListePrelievo.CodLista = dbo.v_righePrelevate.CodLista
ORDER BY dbo.ElencoListePrelievo.DataCreaz DESC
go

commit
go



set xact_abort on
go

begin transaction
go

update ElencoListePrelievo
set Destinatario='-'
where Destinatario is null

commit
go

set xact_abort on
go

begin transaction
go

DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700004' and UDC=N'UMAB310000752'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700004' and UDC=N'UMAB310000754'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700004' and UDC=N'UMAB310000756'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700004' and UDC=N'UMAB310000758'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700005' and UDC=N'UMAB310000752'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700005' and UDC=N'UMAB310000754'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700005' and UDC=N'UMAB310000756'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700005' and UDC=N'UMAB310000758'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700016' and UDC=N'UMAB310000752'
DELETE FROM dbo.RigheListePrelievo WHERE CodLista=N'KMA100700016' and UDC=N'UMAB310000754'
go

commit transaction
go


set xact_abort on
go

begin transaction
go

UPDATE dbo.ElencoListePrelievo SET 
  CodStatoLista=4, Destinatario=N'Gatti'
  WHERE CodLista=N'KMA100700017'
INSERT INTO dbo.ElencoListePrelievo
  VALUES (N'KMA100700019', N'02-PreCli', N'MA', '2010-07-27 12:06:38.443', N'00505 ', N'ZF LENKSYSTEME GmbH', N'O990000000000000', N'P00505005162', N'SCATOLA STERZO DX VOLVO       ', N'7853 501 162                  ', N'*', N'*', N'*', 100.00, 0, N'RoNo')
INSERT INTO dbo.ElencoListePrelievo
  VALUES (N'KMA100700023', N'01-PreFus', N'MA', '2010-07-30 10:57:19.340', N'00505 ', N'ZF LENKSYSTEME GmbH', N'O990000000000000', N'P00505005162', N'SCATOLA STERZO DX VOLVO       ', N'7853 501 162                  ', N'*', N'*', N'*', 120.00, 4, N'-')
INSERT INTO dbo.ElencoListePrelievo
  VALUES (N'KMA100700024', N'01-PreFus', N'MA', '2010-07-30 10:58:24.013', N'00505 ', N'ZF LENKSYSTEME GmbH', N'O990000000000000', N'P00505005162', N'SCATOLA STERZO DX VOLVO       ', N'7853 501 162                  ', N'*', N'*', N'*', 120.00, 4, N'-')
DELETE FROM dbo.ElencoListePrelievo WHERE CodLista=N'KMA100700004'
DELETE FROM dbo.ElencoListePrelievo WHERE CodLista=N'KMA100700005'
DELETE FROM dbo.ElencoListePrelievo WHERE CodLista=N'KMA100700016'
go

commit transaction
go


set xact_abort on
go

begin transaction
go

INSERT INTO dbo.RigheListePrelievo_AS
  VALUES (N'KMA100700017', N'UMAB310000442', 63.00, 1, 1)
INSERT INTO dbo.RigheListePrelievo_AS
  VALUES (N'KMA100700017', N'UMAB310000444', 54.00, 1, 1)
INSERT INTO dbo.RigheListePrelievo_AS
  VALUES (N'KMA100700023', N'UMAB310000004', 56.00, 1, 1)
INSERT INTO dbo.RigheListePrelievo_AS
  VALUES (N'KMA100700023', N'UMAB310001248', 70.00, 1, 1)
INSERT INTO dbo.RigheListePrelievo_AS
  VALUES (N'KMA100700024', N'UMAB310001246', 59.00, 1, 1)
INSERT INTO dbo.RigheListePrelievo_AS
  VALUES (N'KMA100700024', N'UMAB310001250', 65.00, 1, 1)
go

commit transaction
go



set xact_abort on
go

begin transaction
go

alter table ElencoListePrelievo_AS add
  Destinatario nvarchar(50)
go

set ANSI_NULLS on
go

/***************************************
* STORED stp_LP_exportToAs400
*
* esporta la lista di prelievo (e le relative righe) verso AS400 andando a copaire nelle relative tabelle _AS
*
* Steamware, S.E.L.
* mod: 2010.07.19
*
****************************************/
alter PROCEDURE stp_LP_exportToAs400
(
	@CodLista NVARCHAR(12)
)
AS

-- copio la lista (intestazione)
INSERT INTO ElencoListePrelievo_AS
SELECT		*
FROM        ElencoListePrelievo
WHERE       (CodLista = @CodLista)

-- copio le righe lista di dettaglio
INSERT INTO RigheListePrelievo_AS
SELECT		*
FROM        RigheListePrelievo
WHERE       (CodLista = @CodLista) AND Prelevato = 1

-- aggiorno le quantità passate ad AS...
UPDATE		ElencoListePrelievo_AS 
SET			QtaTot = ( SELECT SUM(Qta) AS QtaTot FROM RigheListePrelievo WHERE (CodLista =@CodLista) AND Prelevato = 1 )
WHERE       (CodLista = @CodLista)

RETURN
go

commit
go


set xact_abort on
go

begin transaction
go

INSERT INTO dbo.ElencoListePrelievo_AS
  VALUES (N'KMA100700017', N'03-TerWip', N'MA', '2010-07-27 11:59:22.417', N'00505 ', N'ZF LENKSYSTEME GmbH', N'O990000000000000', N'P00505005162', N'SCATOLA STERZO DX VOLVO       ', N'7853 501 162                  ', N'*', N'*', N'*', 117.00, 4, NULL)
INSERT INTO dbo.ElencoListePrelievo_AS
  VALUES (N'KMA100700023', N'01-PreFus', N'MA', '2010-07-30 10:57:19.340', N'00505 ', N'ZF LENKSYSTEME GmbH', N'O990000000000000', N'P00505005162', N'SCATOLA STERZO DX VOLVO       ', N'7853 501 162                  ', N'*', N'*', N'*', 126.00, 4, NULL)
INSERT INTO dbo.ElencoListePrelievo_AS
  VALUES (N'KMA100700024', N'01-PreFus', N'MA', '2010-07-30 10:58:24.013', N'00505 ', N'ZF LENKSYSTEME GmbH', N'O990000000000000', N'P00505005162', N'SCATOLA STERZO DX VOLVO       ', N'7853 501 162                  ', N'*', N'*', N'*', 124.00, 4, NULL)
go

commit transaction
go

set xact_abort on
go

begin transaction
go

set ANSI_NULLS on
go

/***************************************
* STORED stp_getDestListePrelLike
*
* ottiene l'elenco dei destinatari liste di prelievo data la substring di ricerca
*
* Steamware, S.E.L.
* mod: 2010.07.30
*
****************************************/
create PROCEDURE stp_getDestListePrelLike
(
	@cerca VARCHAR(2)
)
AS

	SELECT * FROM v_selDestinatariListePrelievo
	WHERE Destinatario LIKE '%'+ @cerca  + '%'

RETURN
go

commit
go


set xact_abort on
go

begin transaction
go

UPDATE dbo.Blocchi SET 
  NumX=15, NumY=5
  WHERE IdxBlocco=1
UPDATE dbo.Blocchi SET 
  NumX=15, NumY=5
  WHERE IdxBlocco=4
UPDATE dbo.Blocchi SET 
  NumX=10, NumY=5
  WHERE IdxBlocco=6
DELETE FROM dbo.Blocchi WHERE IdxBlocco=23
DELETE FROM dbo.Blocchi WHERE IdxBlocco=24
go

commit transaction
go


set xact_abort on
go

begin transaction
go

INSERT INTO dbo.PosizioneUdcCorrente
  VALUES (N'UMAB310000114', 57, N'MA', '2010-04-29 01:00:00.000')
UPDATE dbo.PosizioneUdcCorrente SET 
  DataRif='2010-07-28 16:20:57.250'
  WHERE UDC=N'UMAB310000140' and IdxCella=88
INSERT INTO dbo.PosizioneUdcCorrente
  VALUES (N'UMAB310000142', 88, N'MA', '2010-07-28 16:08:06.447')
INSERT INTO dbo.PosizioneUdcCorrente
  VALUES (N'UMAB310000162', 99, N'MA', '2010-04-28 02:00:00.000')
UPDATE dbo.PosizioneUdcCorrente SET 
  DataRif='2010-07-23 18:12:54.563'
  WHERE UDC=N'UMAB310000214' and IdxCella=129
UPDATE dbo.PosizioneUdcCorrente SET 
  DataRif='2010-04-30 01:00:00.000'
  WHERE UDC=N'UMAB310000220' and IdxCella=128
DELETE FROM dbo.PosizioneUdcCorrente WHERE UDC=N'UMAB310000004' and IdxCella=2
DELETE FROM dbo.PosizioneUdcCorrente WHERE UDC=N'UMAB310000114' and IdxCella=499
DELETE FROM dbo.PosizioneUdcCorrente WHERE UDC=N'UMAB310000142' and IdxCella=89
DELETE FROM dbo.PosizioneUdcCorrente WHERE UDC=N'UMAB310000162' and IdxCella=499
DELETE FROM dbo.PosizioneUdcCorrente WHERE UDC=N'UMAB310000442' and IdxCella=76
DELETE FROM dbo.PosizioneUdcCorrente WHERE UDC=N'UMAB310000444' and IdxCella=77
go

commit transaction
go


set xact_abort on
go

begin transaction
go

INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000004', 2, N'MA', '2010-04-15 00:00:00.000', '2010-07-30 11:38:33.483')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000004', 202, N'MA', '2010-07-30 11:38:33.493', '2010-07-30 11:38:38.883')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000140', 88, N'MA', '2010-03-26 01:00:00.000', '2010-07-28 15:50:22.837')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000140', 89, N'MA', '2010-07-28 15:50:22.837', '2010-07-28 16:00:20.507')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000142', 88, N'MA', '2010-07-28 15:49:02.407', '2010-07-28 16:00:05.967')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000142', 89, N'MA', '2010-03-24 00:00:00.000', '2010-07-28 15:49:02.357')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000442', 76, N'MA', '2010-07-19 17:59:09.310', '2010-07-30 12:32:25.000')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000442', 206, N'MA', '2010-07-30 12:32:25.000', '2010-07-30 12:32:28.307')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000444', 77, N'MA', '2010-07-19 17:59:17.063', '2010-07-30 12:32:25.033')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310000444', 206, N'MA', '2010-07-30 12:32:25.033', '2010-07-30 12:32:28.313')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310001246', 202, N'MA', '2010-07-30 12:31:44.230', '2010-07-30 12:31:56.213')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310001248', 202, N'MA', '2010-07-30 12:31:34.947', '2010-07-30 12:31:47.127')
INSERT INTO dbo.PosizioneUdcStorico
  VALUES (N'UMAB310001250', 202, N'MA', '2010-07-30 12:31:44.243', '2010-07-30 12:31:56.230')
DELETE FROM dbo.PosizioneUdcStorico WHERE UDC=N'UMAB310000114' and IdxCella=57
DELETE FROM dbo.PosizioneUdcStorico WHERE UDC=N'UMAB310000162' and IdxCella=99
DELETE FROM dbo.PosizioneUdcStorico WHERE UDC=N'UMAB310000214' and IdxCella=129
DELETE FROM dbo.PosizioneUdcStorico WHERE UDC=N'UMAB310000214' and IdxCella=130
DELETE FROM dbo.PosizioneUdcStorico WHERE UDC=N'UMAB310000214' and IdxCella=139
DELETE FROM dbo.PosizioneUdcStorico WHERE UDC=N'UMAB310000220' and IdxCella=128
DELETE FROM dbo.PosizioneUdcStorico WHERE UDC=N'UMAB310000220' and IdxCella=133
go

commit transaction
go

set xact_abort on
go

begin transaction
go

UPDATE dbo.Celle SET 
  Piena=0
  WHERE IdxCella=5
UPDATE dbo.Celle SET 
  IdxTipoCella=5
  WHERE IdxCella=76
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=80
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=85
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=90
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=95
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=100
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=105
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=110
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=115
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=120
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=125
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=130
UPDATE dbo.Celle SET 
  Attiva=0
  WHERE IdxCella=135
DELETE FROM dbo.Celle WHERE IdxCella=207
DELETE FROM dbo.Celle WHERE IdxCella=208
DELETE FROM dbo.Celle WHERE IdxCella=209
DELETE FROM dbo.Celle WHERE IdxCella=210
DELETE FROM dbo.Celle WHERE IdxCella=211
DELETE FROM dbo.Celle WHERE IdxCella=212
DELETE FROM dbo.Celle WHERE IdxCella=213
DELETE FROM dbo.Celle WHERE IdxCella=214
DELETE FROM dbo.Celle WHERE IdxCella=215
DELETE FROM dbo.Celle WHERE IdxCella=216
DELETE FROM dbo.Celle WHERE IdxCella=217
DELETE FROM dbo.Celle WHERE IdxCella=218
DELETE FROM dbo.Celle WHERE IdxCella=219
DELETE FROM dbo.Celle WHERE IdxCella=220
DELETE FROM dbo.Celle WHERE IdxCella=221
DELETE FROM dbo.Celle WHERE IdxCella=222
DELETE FROM dbo.Celle WHERE IdxCella=223
DELETE FROM dbo.Celle WHERE IdxCella=224
DELETE FROM dbo.Celle WHERE IdxCella=225
DELETE FROM dbo.Celle WHERE IdxCella=226
DELETE FROM dbo.Celle WHERE IdxCella=227
DELETE FROM dbo.Celle WHERE IdxCella=228
DELETE FROM dbo.Celle WHERE IdxCella=229
DELETE FROM dbo.Celle WHERE IdxCella=230
DELETE FROM dbo.Celle WHERE IdxCella=231
DELETE FROM dbo.Celle WHERE IdxCella=232
DELETE FROM dbo.Celle WHERE IdxCella=233
DELETE FROM dbo.Celle WHERE IdxCella=234
DELETE FROM dbo.Celle WHERE IdxCella=235
DELETE FROM dbo.Celle WHERE IdxCella=236
DELETE FROM dbo.Celle WHERE IdxCella=237
DELETE FROM dbo.Celle WHERE IdxCella=238
DELETE FROM dbo.Celle WHERE IdxCella=239
DELETE FROM dbo.Celle WHERE IdxCella=240
DELETE FROM dbo.Celle WHERE IdxCella=241
DELETE FROM dbo.Celle WHERE IdxCella=242
DELETE FROM dbo.Celle WHERE IdxCella=243
DELETE FROM dbo.Celle WHERE IdxCella=244
DELETE FROM dbo.Celle WHERE IdxCella=245
DELETE FROM dbo.Celle WHERE IdxCella=246
DELETE FROM dbo.Celle WHERE IdxCella=247
DELETE FROM dbo.Celle WHERE IdxCella=248
DELETE FROM dbo.Celle WHERE IdxCella=249
DELETE FROM dbo.Celle WHERE IdxCella=250
DELETE FROM dbo.Celle WHERE IdxCella=251
DELETE FROM dbo.Celle WHERE IdxCella=252
DELETE FROM dbo.Celle WHERE IdxCella=253
DELETE FROM dbo.Celle WHERE IdxCella=254
DELETE FROM dbo.Celle WHERE IdxCella=255
DELETE FROM dbo.Celle WHERE IdxCella=256
DELETE FROM dbo.Celle WHERE IdxCella=257
DELETE FROM dbo.Celle WHERE IdxCella=258
DELETE FROM dbo.Celle WHERE IdxCella=259
DELETE FROM dbo.Celle WHERE IdxCella=260
DELETE FROM dbo.Celle WHERE IdxCella=261
DELETE FROM dbo.Celle WHERE IdxCella=262
DELETE FROM dbo.Celle WHERE IdxCella=263
DELETE FROM dbo.Celle WHERE IdxCella=264
DELETE FROM dbo.Celle WHERE IdxCella=265
DELETE FROM dbo.Celle WHERE IdxCella=266
DELETE FROM dbo.Celle WHERE IdxCella=267
DELETE FROM dbo.Celle WHERE IdxCella=268
DELETE FROM dbo.Celle WHERE IdxCella=269
DELETE FROM dbo.Celle WHERE IdxCella=270
DELETE FROM dbo.Celle WHERE IdxCella=271
DELETE FROM dbo.Celle WHERE IdxCella=272
DELETE FROM dbo.Celle WHERE IdxCella=273
DELETE FROM dbo.Celle WHERE IdxCella=274
DELETE FROM dbo.Celle WHERE IdxCella=275
DELETE FROM dbo.Celle WHERE IdxCella=276
DELETE FROM dbo.Celle WHERE IdxCella=277
DELETE FROM dbo.Celle WHERE IdxCella=278
DELETE FROM dbo.Celle WHERE IdxCella=279
DELETE FROM dbo.Celle WHERE IdxCella=280
DELETE FROM dbo.Celle WHERE IdxCella=281
DELETE FROM dbo.Celle WHERE IdxCella=282
DELETE FROM dbo.Celle WHERE IdxCella=283
DELETE FROM dbo.Celle WHERE IdxCella=284
DELETE FROM dbo.Celle WHERE IdxCella=285
DELETE FROM dbo.Celle WHERE IdxCella=286
DELETE FROM dbo.Celle WHERE IdxCella=287
DELETE FROM dbo.Celle WHERE IdxCella=288
DELETE FROM dbo.Celle WHERE IdxCella=289
DELETE FROM dbo.Celle WHERE IdxCella=290
DELETE FROM dbo.Celle WHERE IdxCella=291
DELETE FROM dbo.Celle WHERE IdxCella=292
DELETE FROM dbo.Celle WHERE IdxCella=293
DELETE FROM dbo.Celle WHERE IdxCella=294
DELETE FROM dbo.Celle WHERE IdxCella=295
DELETE FROM dbo.Celle WHERE IdxCella=296
DELETE FROM dbo.Celle WHERE IdxCella=297
DELETE FROM dbo.Celle WHERE IdxCella=298
DELETE FROM dbo.Celle WHERE IdxCella=299
DELETE FROM dbo.Celle WHERE IdxCella=300
DELETE FROM dbo.Celle WHERE IdxCella=301
DELETE FROM dbo.Celle WHERE IdxCella=302
DELETE FROM dbo.Celle WHERE IdxCella=303
DELETE FROM dbo.Celle WHERE IdxCella=304
DELETE FROM dbo.Celle WHERE IdxCella=305
DELETE FROM dbo.Celle WHERE IdxCella=306
DELETE FROM dbo.Celle WHERE IdxCella=307
DELETE FROM dbo.Celle WHERE IdxCella=308
DELETE FROM dbo.Celle WHERE IdxCella=309
DELETE FROM dbo.Celle WHERE IdxCella=310
DELETE FROM dbo.Celle WHERE IdxCella=311
DELETE FROM dbo.Celle WHERE IdxCella=312
DELETE FROM dbo.Celle WHERE IdxCella=313
DELETE FROM dbo.Celle WHERE IdxCella=314
DELETE FROM dbo.Celle WHERE IdxCella=315
DELETE FROM dbo.Celle WHERE IdxCella=316
DELETE FROM dbo.Celle WHERE IdxCella=317
DELETE FROM dbo.Celle WHERE IdxCella=318
DELETE FROM dbo.Celle WHERE IdxCella=319
DELETE FROM dbo.Celle WHERE IdxCella=320
DELETE FROM dbo.Celle WHERE IdxCella=321
DELETE FROM dbo.Celle WHERE IdxCella=322
DELETE FROM dbo.Celle WHERE IdxCella=323
DELETE FROM dbo.Celle WHERE IdxCella=324
DELETE FROM dbo.Celle WHERE IdxCella=325
DELETE FROM dbo.Celle WHERE IdxCella=326
DELETE FROM dbo.Celle WHERE IdxCella=327
DELETE FROM dbo.Celle WHERE IdxCella=328
DELETE FROM dbo.Celle WHERE IdxCella=329
DELETE FROM dbo.Celle WHERE IdxCella=330
DELETE FROM dbo.Celle WHERE IdxCella=331
DELETE FROM dbo.Celle WHERE IdxCella=332
DELETE FROM dbo.Celle WHERE IdxCella=333
DELETE FROM dbo.Celle WHERE IdxCella=334
DELETE FROM dbo.Celle WHERE IdxCella=335
DELETE FROM dbo.Celle WHERE IdxCella=336
DELETE FROM dbo.Celle WHERE IdxCella=337
DELETE FROM dbo.Celle WHERE IdxCella=338
DELETE FROM dbo.Celle WHERE IdxCella=339
DELETE FROM dbo.Celle WHERE IdxCella=340
DELETE FROM dbo.Celle WHERE IdxCella=341
DELETE FROM dbo.Celle WHERE IdxCella=342
DELETE FROM dbo.Celle WHERE IdxCella=343
DELETE FROM dbo.Celle WHERE IdxCella=344
DELETE FROM dbo.Celle WHERE IdxCella=345
DELETE FROM dbo.Celle WHERE IdxCella=346
DELETE FROM dbo.Celle WHERE IdxCella=347
DELETE FROM dbo.Celle WHERE IdxCella=348
DELETE FROM dbo.Celle WHERE IdxCella=349
DELETE FROM dbo.Celle WHERE IdxCella=350
DELETE FROM dbo.Celle WHERE IdxCella=351
DELETE FROM dbo.Celle WHERE IdxCella=352
DELETE FROM dbo.Celle WHERE IdxCella=353
DELETE FROM dbo.Celle WHERE IdxCella=354
DELETE FROM dbo.Celle WHERE IdxCella=355
DELETE FROM dbo.Celle WHERE IdxCella=356
DELETE FROM dbo.Celle WHERE IdxCella=357
DELETE FROM dbo.Celle WHERE IdxCella=358
DELETE FROM dbo.Celle WHERE IdxCella=359
DELETE FROM dbo.Celle WHERE IdxCella=360
DELETE FROM dbo.Celle WHERE IdxCella=361
DELETE FROM dbo.Celle WHERE IdxCella=362
DELETE FROM dbo.Celle WHERE IdxCella=363
DELETE FROM dbo.Celle WHERE IdxCella=364
DELETE FROM dbo.Celle WHERE IdxCella=365
DELETE FROM dbo.Celle WHERE IdxCella=366
DELETE FROM dbo.Celle WHERE IdxCella=367
DELETE FROM dbo.Celle WHERE IdxCella=368
DELETE FROM dbo.Celle WHERE IdxCella=369
DELETE FROM dbo.Celle WHERE IdxCella=370
DELETE FROM dbo.Celle WHERE IdxCella=371
DELETE FROM dbo.Celle WHERE IdxCella=372
DELETE FROM dbo.Celle WHERE IdxCella=373
DELETE FROM dbo.Celle WHERE IdxCella=374
DELETE FROM dbo.Celle WHERE IdxCella=375
DELETE FROM dbo.Celle WHERE IdxCella=376
DELETE FROM dbo.Celle WHERE IdxCella=377
DELETE FROM dbo.Celle WHERE IdxCella=378
DELETE FROM dbo.Celle WHERE IdxCella=379
DELETE FROM dbo.Celle WHERE IdxCella=380
DELETE FROM dbo.Celle WHERE IdxCella=381
DELETE FROM dbo.Celle WHERE IdxCella=382
DELETE FROM dbo.Celle WHERE IdxCella=383
DELETE FROM dbo.Celle WHERE IdxCella=384
DELETE FROM dbo.Celle WHERE IdxCella=385
DELETE FROM dbo.Celle WHERE IdxCella=386
DELETE FROM dbo.Celle WHERE IdxCella=387
DELETE FROM dbo.Celle WHERE IdxCella=388
DELETE FROM dbo.Celle WHERE IdxCella=389
DELETE FROM dbo.Celle WHERE IdxCella=390
DELETE FROM dbo.Celle WHERE IdxCella=391
DELETE FROM dbo.Celle WHERE IdxCella=392
DELETE FROM dbo.Celle WHERE IdxCella=393
DELETE FROM dbo.Celle WHERE IdxCella=394
DELETE FROM dbo.Celle WHERE IdxCella=395
DELETE FROM dbo.Celle WHERE IdxCella=396
DELETE FROM dbo.Celle WHERE IdxCella=397
DELETE FROM dbo.Celle WHERE IdxCella=398
DELETE FROM dbo.Celle WHERE IdxCella=399
DELETE FROM dbo.Celle WHERE IdxCella=400
DELETE FROM dbo.Celle WHERE IdxCella=401
DELETE FROM dbo.Celle WHERE IdxCella=402
DELETE FROM dbo.Celle WHERE IdxCella=403
DELETE FROM dbo.Celle WHERE IdxCella=404
DELETE FROM dbo.Celle WHERE IdxCella=405
DELETE FROM dbo.Celle WHERE IdxCella=406
DELETE FROM dbo.Celle WHERE IdxCella=407
DELETE FROM dbo.Celle WHERE IdxCella=408
DELETE FROM dbo.Celle WHERE IdxCella=409
DELETE FROM dbo.Celle WHERE IdxCella=410
DELETE FROM dbo.Celle WHERE IdxCella=411
DELETE FROM dbo.Celle WHERE IdxCella=412
DELETE FROM dbo.Celle WHERE IdxCella=413
DELETE FROM dbo.Celle WHERE IdxCella=414
DELETE FROM dbo.Celle WHERE IdxCella=415
DELETE FROM dbo.Celle WHERE IdxCella=416
DELETE FROM dbo.Celle WHERE IdxCella=417
DELETE FROM dbo.Celle WHERE IdxCella=418
DELETE FROM dbo.Celle WHERE IdxCella=419
DELETE FROM dbo.Celle WHERE IdxCella=420
DELETE FROM dbo.Celle WHERE IdxCella=421
DELETE FROM dbo.Celle WHERE IdxCella=422
DELETE FROM dbo.Celle WHERE IdxCella=423
DELETE FROM dbo.Celle WHERE IdxCella=424
DELETE FROM dbo.Celle WHERE IdxCella=425
DELETE FROM dbo.Celle WHERE IdxCella=426
DELETE FROM dbo.Celle WHERE IdxCella=427
DELETE FROM dbo.Celle WHERE IdxCella=428
DELETE FROM dbo.Celle WHERE IdxCella=429
DELETE FROM dbo.Celle WHERE IdxCella=430
DELETE FROM dbo.Celle WHERE IdxCella=431
DELETE FROM dbo.Celle WHERE IdxCella=432
DELETE FROM dbo.Celle WHERE IdxCella=433
DELETE FROM dbo.Celle WHERE IdxCella=434
DELETE FROM dbo.Celle WHERE IdxCella=435
DELETE FROM dbo.Celle WHERE IdxCella=436
DELETE FROM dbo.Celle WHERE IdxCella=437
DELETE FROM dbo.Celle WHERE IdxCella=438
DELETE FROM dbo.Celle WHERE IdxCella=439
DELETE FROM dbo.Celle WHERE IdxCella=440
DELETE FROM dbo.Celle WHERE IdxCella=441
DELETE FROM dbo.Celle WHERE IdxCella=442
DELETE FROM dbo.Celle WHERE IdxCella=443
DELETE FROM dbo.Celle WHERE IdxCella=444
DELETE FROM dbo.Celle WHERE IdxCella=445
DELETE FROM dbo.Celle WHERE IdxCella=446
DELETE FROM dbo.Celle WHERE IdxCella=447
DELETE FROM dbo.Celle WHERE IdxCella=448
DELETE FROM dbo.Celle WHERE IdxCella=449
DELETE FROM dbo.Celle WHERE IdxCella=450
DELETE FROM dbo.Celle WHERE IdxCella=451
DELETE FROM dbo.Celle WHERE IdxCella=452
DELETE FROM dbo.Celle WHERE IdxCella=453
DELETE FROM dbo.Celle WHERE IdxCella=454
DELETE FROM dbo.Celle WHERE IdxCella=455
DELETE FROM dbo.Celle WHERE IdxCella=456
DELETE FROM dbo.Celle WHERE IdxCella=457
DELETE FROM dbo.Celle WHERE IdxCella=458
DELETE FROM dbo.Celle WHERE IdxCella=459
DELETE FROM dbo.Celle WHERE IdxCella=460
DELETE FROM dbo.Celle WHERE IdxCella=461
DELETE FROM dbo.Celle WHERE IdxCella=462
DELETE FROM dbo.Celle WHERE IdxCella=463
DELETE FROM dbo.Celle WHERE IdxCella=464
DELETE FROM dbo.Celle WHERE IdxCella=465
DELETE FROM dbo.Celle WHERE IdxCella=466
DELETE FROM dbo.Celle WHERE IdxCella=467
DELETE FROM dbo.Celle WHERE IdxCella=468
DELETE FROM dbo.Celle WHERE IdxCella=469
DELETE FROM dbo.Celle WHERE IdxCella=470
DELETE FROM dbo.Celle WHERE IdxCella=471
DELETE FROM dbo.Celle WHERE IdxCella=472
DELETE FROM dbo.Celle WHERE IdxCella=473
DELETE FROM dbo.Celle WHERE IdxCella=474
DELETE FROM dbo.Celle WHERE IdxCella=475
DELETE FROM dbo.Celle WHERE IdxCella=476
DELETE FROM dbo.Celle WHERE IdxCella=477
DELETE FROM dbo.Celle WHERE IdxCella=478
DELETE FROM dbo.Celle WHERE IdxCella=479
DELETE FROM dbo.Celle WHERE IdxCella=480
DELETE FROM dbo.Celle WHERE IdxCella=481
DELETE FROM dbo.Celle WHERE IdxCella=482
DELETE FROM dbo.Celle WHERE IdxCella=483
DELETE FROM dbo.Celle WHERE IdxCella=484
DELETE FROM dbo.Celle WHERE IdxCella=485
DELETE FROM dbo.Celle WHERE IdxCella=486
DELETE FROM dbo.Celle WHERE IdxCella=487
DELETE FROM dbo.Celle WHERE IdxCella=488
DELETE FROM dbo.Celle WHERE IdxCella=489
DELETE FROM dbo.Celle WHERE IdxCella=490
DELETE FROM dbo.Celle WHERE IdxCella=491
DELETE FROM dbo.Celle WHERE IdxCella=492
DELETE FROM dbo.Celle WHERE IdxCella=493
DELETE FROM dbo.Celle WHERE IdxCella=494
DELETE FROM dbo.Celle WHERE IdxCella=495
DELETE FROM dbo.Celle WHERE IdxCella=496
DELETE FROM dbo.Celle WHERE IdxCella=497
DELETE FROM dbo.Celle WHERE IdxCella=498
DELETE FROM dbo.Celle WHERE IdxCella=499
DELETE FROM dbo.Celle WHERE IdxCella=500
go

commit transaction
go


set xact_abort on
go

begin transaction
go

UPDATE dbo.TipoCella SET 
  Quantita=200, Capienza=3, Max_X=3000, Max_Kg=3000
  WHERE IdxTipoCella=5
DELETE FROM dbo.TipoCella WHERE IdxTipoCella=16
DELETE FROM dbo.TipoCella WHERE IdxTipoCella=17
DELETE FROM dbo.TipoCella WHERE IdxTipoCella=18
go

commit transaction
go







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