Mssql All Tables To Csv

13.01.2019
• Bilgisayar

Mssql All Tables To Csv

An easy way to extract all table to csv or txt file in MSSQL is just run in SMSS and then copy sql result and run in cmd .


use database ;
SELECT 'bcp ' +
            QUOTENAME(DB_NAME())
            + '.'
            +QUOTENAME(SCHEMA_NAME(schema_id))
            + '.'
            +QUOTENAME(name)
            + ' '+'out'+' c:\target\'
            + name + '.csv -w -t"|" -E -S '
            + @@servername
            + ' -T'
    FROM sys.objects
    WHERE TYPE='u'
        AND is_ms_shipped=0
       
        order by name

Copy all and run in CMD.


That is all+.