Search code examples
sql-serversql-server-2017-express

SQL Server export table to .dat file


I'm using SQL Server 2017 Express, I have an eventlog table and i would like to export it to a .dat file, in order to reduce the size of my database. Is there any possible way to do this. Can anyone give me a hint about it if it's possible?

Thank you.


Solution

  • You can bcp out (export) your table as .dat file. try the following:

    using Command prompt:

    bcp dbname.schemaname.eventlog out "path\eventlog.dat" -T -c'
    

    or

    within SQL server:

    exec master..xp_cmdshell 'bcp "dbname.schemaname.eventlog" out "path\eventlog.dat" -T -c'
    

    bcp Utility Details