Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @FieldName sysname,
- @TableName sysname;
- DECLARE MCursorCA CURSOR FOR
- SELECT
- t.TABLE_NAME, c.COLUMN_NAME
- FROM
- information_schema.TABLES t
- INNER JOIN
- information_schema.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME
- WHERE
- c.DATA_TYPE = 'decimal' AND
- ((t.TABLE_NAME LIKE 'sa%') or (t.TABLE_NAME like 'sb%')) and
- c.column_name NOT IN (
- 'Existen', 'ExistenCon', 'ExInicial', 'ExistAnt', 'ExFinal', 'ExUnidadCon',
- 'ExistAnt2', 'ExistAntU', 'ExistAntU2', 'ExUndFinal', 'ExUndIni', 'ExUnidad',
- 'Maximo', 'Minimo', 'Pedido', 'Faltante',
- 'MontoMEx', 'SaldoMEx',
- 'UnidCom', 'UnidPed', 'Unidad', 'unidserv',
- 'CntCargos', 'CntCompra',
- 'CntDescarg', 'CntInicial',
- 'CntVentas', 'CntTraslad',
- 'Cant', 'CantCom', 'CantEmpaq', 'cantidad', 'Cantidad_O', 'CantidadA', 'CantidadC', 'CantidadO',
- 'CantidadU', 'CantidadUA', 'CantMayor', 'CantPed', 'cantusada',
- 'PrecioI1', 'PrecioI2', 'PrecioI3',
- 'Nro_Compras', 'Nro_Devoluciones', 'Nro_N_Creditos', 'Nro_N_Debitos', 'Nro_Pagos', 'Nro_Ventas',
- 'NroColonias', 'NroComp', 'NroComps', 'NroCtrl', 'NroCtrol', 'NroCuenta', 'NroCxB','NroDcto', 'NroDcts',
- 'NroDevol', 'NroEgreso', 'NroEstable', 'NroFacts', 'NroFinal', 'NroIDOP', 'NroILB', 'NroInicio',
- 'NroLinea', 'NroLineaC', 'NroLote', 'NroNCredito', 'NroNDebito', 'NroOPago', 'NroOper', 'NroPagos',
- 'NroPpal', 'NroRegi', 'NroRpt', 'NroSerial', 'NroUCxP', 'NroUnico', 'NroUnicoL', 'NroURecP', 'NroURetP', 'NroUTrnB',
- 'Tara', 'Peso', 'Volumen',
- 'porc1', 'porc2',
- 'porc3', 'Porcent', 'PorcReten', 'PorctReten', 'PorctUtil',
- 'PDB', 'FData',
- 'PrxCheque',
- 'PDebBan',
- 'PBD',
- 'MontoBT',
- 'BaseIT',
- 'ComiT',
- 'PDebBan',
- 'ImpT',
- 'BaseTr',
- 'ValorPtos', 'ValorPtosV','SaldoPtos',
- 'Desde', 'Hasta',
- 'Costo_DV', 'Gasto_DV', 'Precio_DV')
- AND t.table_type = 'BASE TABLE'
- AND charindex('_', t.TABLE_NAME) = 0 AND
- NOT t.TABLE_NAME LIKE 'SACVEN' AND
- NOT t.TABLE_NAME LIKE 'SARGOCAT' AND
- NOT t.TABLE_NAME LIKE 'SAPRIMCOM' AND
- NOT t.TABLE_NAME LIKE 'SAPRIM' AND
- NOT t.TABLE_NAME LIKE 'SATABL' AND
- NOT t.TABLE_NAME LIKE 'SAFIEL' AND
- NOT t.TABLE_NAME LIKE 'SACLICNV' AND
- NOT t.TABLE_NAME LIKE 'SAGRUPOS' AND
- NOT t.TABLE_NAME LIKE 'SAAOPER' AND
- NOT t.TABLE_NAME LIKE 'SACAMPOS' AND
- NOT t.TABLE_NAME LIKE 'SACMEC' AND
- NOT t.TABLE_NAME LIKE 'SAMECA' AND
- NOT t.TABLE_NAME LIKE 'SACOLLERSIS' AND
- NOT t.TABLE_NAME LIKE 'SASNNOTIF' AND
- NOT t.TABLE_NAME LIKE 'SBRptD' AND
- NOT t.TABLE_NAME LIKE 'SBOpFr' AND
- NOT t.TABLE_NAME LIKE 'SBCONF' AND
- NOT ((c.COLUMN_NAME LIKE 'Desde') AND (t.TABLE_NAME='SAITCV')) AND
- NOT ((c.COLUMN_NAME LIKE 'Compro') AND (t.TABLE_NAME='SAPROD')) AND
- NOT ((c.COLUMN_NAME LIKE 'Hasta') AND (t.TABLE_NAME='SAITCV')) AND
- NOT ((c.COLUMN_NAME LIKE 'Monto') AND (t.TABLE_NAME='SAITCV')) AND
- NOT ((c.COLUMN_NAME LIKE 'Descto') AND (t.TABLE_NAME='SAINSTA')) AND
- NOT ((c.COLUMN_NAME LIKE 'Descto') AND (t.TABLE_NAME='SACLIE')) AND
- NOT ((c.COLUMN_NAME LIKE 'Monto') AND (t.TABLE_NAME='SARGOTJT')) AND
- NOT ((c.COLUMN_NAME LIKE 'Monto') AND (t.TABLE_NAME='SATAXPRD')) AND
- NOT ((c.COLUMN_NAME LIKE 'Monto') AND (t.TABLE_NAME='SATAXSRV')) AND
- NOT ((c.COLUMN_NAME LIKE 'MtoTax') AND (t.TABLE_NAME='SATAXITF')) AND
- NOT ((c.COLUMN_NAME LIKE 'MtoTax') AND (t.TABLE_NAME='SATAXITC')) AND
- NOT ((c.COLUMN_NAME LIKE 'MtoTax') AND (t.TABLE_NAME='SATAXVTA')) AND
- NOT ((c.COLUMN_NAME LIKE 'MtoTax') AND (t.TABLE_NAME='SATAXCXC')) AND
- NOT ((c.COLUMN_NAME LIKE 'MtoTax') AND (t.TABLE_NAME='SATAXCOM')) AND
- NOT ((c.COLUMN_NAME LIKE 'MtoTax') AND (t.TABLE_NAME='SATAXCXP')) AND
- NOT ((c.COLUMN_NAME LIKE 'MtoTax') AND (t.TABLE_NAME='SATAXES')) AND
- NOT ((c.COLUMN_NAME LIKE 'Impuesto') AND (t.TABLE_NAME='SATARJ'))
- ORDER BY
- t.TABLE_NAME, c.COLUMN_NAME
- OPEN MCursorCA;
- FETCH NEXT FROM MCursorCA
- INTO @TableName,
- @FieldName;
- WHILE @@FETCH_STATUS = 0
- BEGIN
- EXEC ('UPDATE ' + @TableName + ' SET ' + @FieldName + '=ISNULL(ROUND(' + @FieldName + '/1000000,3),0.0)');
- PRINT ('UPDATE ' + @TableName + ' SET ' + @FieldName + '=ISNULL(ROUND(' + @FieldName + '/1000000,3),0.0)');
- FETCH NEXT FROM MCursorCA
- INTO @TableName,
- @FieldName;
- END;
- CLOSE MCursorCA;
- DEALLOCATE MCursorCA;
- /*
- SELECT t.TABLE_NAME,
- ('update ' + t.TABLE_NAME + ' set ' + c.COLUMN_NAME + ' = round(convert(decimal, isnull(' + c.COLUMN_NAME + ', 0.00)) / 1000000, 2)') AS Conversion
- ,c.column_name
- FROM information_schema.TABLES t INNER JOIN
- information_schema.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME
- WHERE
- c.DATA_TYPE = 'decimal' AND t.TABLE_TYPE = 'BASE TABLE'
- */
Add Comment
Please, Sign In to add comment