views:

113

answers:

1

I'm not an expert with either System.Data nor SQL Server, but have a need to generate a large DataSet then use System.Data.SqlClient.SqlBulkCopy to store the results.

The DataSet will consist of about 10 related tables. When SqlBulkCopy transfers the DataSet to SQL Server, my understanding is that rows from the various DataTables will get integrated with the existing SQL tables, maintaining relationships and constraints.

Rather than building DataTables by hand and manually setting relations and constraints, and rather than creating an XML Schema Definition, is there an easy way to load multiple table definitions, constraints, and foreign key definitions from SQL directly into a DataSet?

If not, what approach would you recommend?

+4  A: 

You can use DataAdapter.FillSchema.

Chris McCall