0

Possible Duplicate:
Microsoft SQL alternative for Oracle's Imp and Exp command

I'm looking a command line tool or SQL command to export/import a table or complete database. Much like the imp and exp commands of Oracle databases.

Any suggestions?

1
  • I'm not trying to migrate to another server, just export all the tables in the database
    – ferdyh
    May 11, 2011 at 9:05

2 Answers 2

1

If you're running MS SQL Server 2005 I think what you are looking for is Integration Services. This is a product which does many things including import and export. This replaces Data Transformation Services which is your main option on earlier versions.

The easiest way of managing this is to use the Import and Export Wizard in SQL Server Management Studio, although there are other ways of invoking it. Find out more.

1
  • The problem is that we need to run it from either the commandline or from within an sql statement, since its integrated in our application.
    – ferdyh
    May 10, 2011 at 12:19
0

The SQL Server feature that is most like imp or exp is probably bcp. I believe that bcp.exe ships with the "standard" SQL tools. SSIS server objects do not ship with the standard tools and you may run into licensing issues if you are not running your app on the SQL Server.

BCP is a utility that allows data to be exported from a table to a file or imported from a file to a table. BCP has been shipping with SQL Server for something like 20 years, and it is very primitive. It only understands getting data from tables to files or from files to tables. It does not handle creation tables or indexes. It does not handle parent-child relationships. If you need to export/import many tables, you will have to do them one at a time. If you need to create objects on the destination, your best bet is to use the automated script creation features of SSMS to create scripts that will create your tables and indexes. You can then run those scripts on the destination.

BCP uses the standard "fast load" interfaces, which are exposed via OLEDB. If program is written in .Net, you should be able to use those interfaces to code up your own transfers. This would be a better solution than shelling out because you don't have to worry about whether or not a third party utility is on the client machine.

Another way to handle this would be with linked servers, but they tend to be slow and large transfers may require a lot of log file space.

If you need to do this on a regular basis, you might want to look at snapshot replication. This is a server-side solution that requires some set up and configuration.

1
  • The downside of BCP is that it is not capable of exporting multiple tables. In Exp you can specify FULL=Y to export all the tables.
    – ferdyh
    May 11, 2011 at 13:23

Not the answer you're looking for? Browse other questions tagged .