2

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.

we_mor
  • 478
  • 5
  • 20
  • Can you create another SQL Server? I am thinking a new SQL Server instance just for storing the old data and moving the data via a linked server+delete. The upside is you can still easily query it if need be. If you don't care about that, why back it up at all? – UnhandledExcepSean Oct 05 '18 at 13:41
  • What do you mean `dat` file? That's not a specific format. Storing data into another file won't take *less* space either, unless you move it to another disk – Panagiotis Kanavos Oct 05 '18 at 13:50
  • The Export Data task in SSMS can export data to multiple targets, including flat files, Access, Excel, other databases – Panagiotis Kanavos Oct 05 '18 at 13:51

1 Answers1

4

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

sacse
  • 3,634
  • 2
  • 15
  • 24