BEGIN TRANSACTION; 
GO 
ALTER TABLE Trn_Kardex ADD BaseIvp MONEY,TarifaIvp DECIMAL(14,4),IvaIngProd MONEY
GO
CREATE NONCLUSTERED INDEX [IX_Trn_KardexBaseIvp] ON Trn_Kardex
(
	[BaseIvp] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Trn_KardexTarifaIvp] ON Trn_Kardex
(
	[TarifaIvp] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Trn_KardexIvaIngProd] ON Trn_Kardex
(
	[IvaIngProd] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
DECLARE @i INT=1
WHILE( @i <= (select (count(*)/10000)+1 from Trn_Kardex) )
  BEGIN
      UPDATE TOP(10000) Trn_Kardex SET BaseIvp = 0 WHERE BaseIvp is null
      UPDATE TOP(10000) Trn_Kardex SET TarifaIvp = 0 WHERE TarifaIvp is null
	  UPDATE TOP(10000) Trn_Kardex SET IvaIngProd = 0 WHERE IvaIngProd is null
      SET @i=@i + 1
  END
GO
DROP INDEX [IX_Trn_KardexBaseIvp] ON Trn_Kardex
GO
DROP INDEX [IX_Trn_KardexTarifaIvp] ON Trn_Kardex
GO
DROP INDEX [IX_Trn_KardexIvaIngProd] ON Trn_Kardex
GO
ALTER TABLE Trn_Kardex ALTER COLUMN BaseIvp MONEY NOT NULL
GO
ALTER TABLE Trn_Kardex ALTER COLUMN TarifaIvp DECIMAL(14,4) NOT NULL
GO
ALTER TABLE Trn_Kardex ALTER COLUMN IvaIngProd MONEY NOT NULL
GO
COMMIT TRANSACTION; 
GO