Export data from a SQL Server table

Import and export data from Microsoft SQL Server provides the tool bpc, which operates by command line. Although it would be appreciated if SQL Server Management Studio provides a graphical utility for import / export that we avoid having to use the command line, bpc is very easy to use, at least to do simple things.

It is also the most efficient methods to export or import data into SQL Server. The basic syntax for this command is this:

bcp table or query} {{in / out} nombre_del_fichero [options] The options can be comescrow enough, and you can even build and use format files, but for most of the cases may be sufficient to use the most basic options that allow us to use a file for export / import data from a table:

  • Export data in table 'mytable' of BD 'MyDatabase' in the file 'datosdemitabla.txt' > Bcp mibasededatos.miusuario.mitabla out c: \ mydir \ datosdemitabla.txt-c-T
  • Importing data from file 'datosdemitabla.txt' on table 'miotratabla' of BD 'miotrabasededatos': > Bcp miotrabasededatos.miusuario.miotratabla in c: \ mydir \ datosdemitabla.txt-c-T

Easy, don't? But if, for example, export the data that we use to do a migration to another database manager other than SQL Server, we must further refine the use of options for the definition of the file format for it to be compatible Import utility with the other DBMS that we will use, or we can also raise other options:

Importing a data file with INSERTS from phpmyadmin (MySQL)

  • Another option would be to use a tool that can connect to different database managers, and have capacities of export / import.With Oracle SQL Developer , for example, you can work from the same environment coNo Oracle databases, SQL Server, Access and MySQL. It does export to a file from the database source and then import it the file from the database destination. SQL Server Export data from Oracle SQL Developer