Convert SQL Numeric Columns to CSV
Extract INTEGER, DECIMAL, FLOAT, and other numeric SQL types to CSV. Numeric values are output without quotes unless they contain special characters.
Detailed Explanation
Numeric Types in SQL to CSV Conversion
SQL databases support various numeric types — INTEGER, BIGINT, DECIMAL, FLOAT, DOUBLE, NUMERIC, and more. When converting to CSV, the tool preserves numeric values exactly as they appear in the INSERT statement, without adding unnecessary quotes.
Example SQL
CREATE TABLE financial_data (
id INTEGER PRIMARY KEY,
account_name VARCHAR(100),
balance DECIMAL(12,2),
interest_rate FLOAT,
transactions INTEGER,
credit_score SMALLINT
);
INSERT INTO financial_data VALUES
(1, 'Savings Account', 15432.89, 0.025, 142, 750),
(2, 'Checking Account', -234.50, 0.001, 1893, 680),
(3, 'Investment Fund', 1250000.00, 0.0725, 37, NULL),
(4, 'Emergency Fund', 5000.00, 0.015, 12, 750);
Generated CSV
id,account_name,balance,interest_rate,transactions,credit_score
1,Savings Account,15432.89,0.025,142,750
2,Checking Account,-234.50,0.001,1893,680
3,Investment Fund,1250000.00,0.0725,37,
4,Emergency Fund,5000.00,0.015,12,750
Key Behaviors
- Decimal precision: Values like
15432.89are preserved exactly as written in SQL - Negative numbers: Handled correctly without additional quoting
- Scientific notation: Values like
1.5e10are preserved as-is - Leading zeros: SQL integer
007becomes007in CSV (preserved as a string) - NULL numerics: Converted according to the NULL representation setting
CSV Quoting for Numerics
Numeric values are only quoted in the CSV output if they happen to contain the delimiter character (unlikely but possible with certain decimal separators). Standard numeric values remain unquoted for maximum compatibility with spreadsheet imports.
Use Case
Exporting financial data, analytics metrics, or scientific measurements from SQL databases for analysis in tools that expect numeric CSV columns without extraneous quoting.