0

I'd like to make a program module that exports all records from three tables in a database into a file at once(I means not adding row by row, maybe like BULK). Here I have some questions

  1. Is it possible to export records of three tables into a file? Or a file per table?
  2. At exporting or importing, I don't want to insert row by row. I wanna do all records at once. Can we do it in programming?
  3. For MS SQL 2005 Express and VS 2005, which data provider should i use?
  4. How about Importing to SQL 2005 Express?
icedwater
  • 4,701
  • 3
  • 35
  • 50
soclose
  • 2,773
  • 12
  • 51
  • 60

3 Answers3

1

Actually you can export a table into an xml file with an sql statement like the following:

SELECT * FROM TABLENAMES FOR XML AUTO,ROOT('filename')

this is an attribute based xml file,to make it element based send a command like the following:

SELECT * FROM TABLENAMES FOR XML AUTO,ELEMENTS ROOT('filename')

Qqbt
  • 802
  • 2
  • 8
  • 33
0

It is possible to export a Table into a File? Yes. Is it supported in a manner that you can just perform it in a few lines of code? No it isn't (unless I've vastly overlooked some part of SQL or .NET).

You will need to do something where you read the information from the database into either a DataReader, DataSet, or DataTable then iterate over the information to create the file format of your choice.

Your statement would look as follows

Select * From Table

You can do BULK Inserts on SQL, and the above is how you would read in BULK

To connect to SQLServer through VB.NET (and .NET in general) regardless of the version you will want to use the

SQLClient namespace and then various parts of that: SQLConnection, SQLCommand

msarchet
  • 15,104
  • 2
  • 43
  • 66
0

Using bcp to Export / Import

In exporting to excel file, we can put data from table per sheet. I haven't tested this by using bcp.

soclose
  • 2,773
  • 12
  • 51
  • 60