Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create XSD from SQL Server Database

Status
Not open for further replies.

ifmo114

Programmer
Feb 27, 2002
15
US
Any code tips on creating a single XSD file for a SQL Server database with many tables?

Thanks.
 
Fill a DataSet, and call the DataSetName.WriteXMLSchema() method.
 
Thanks, but how do I fill a DataSet with an entire database (over 50 tables) so I get one xsd for the entire DB? Do I just write one big sql statement that joins every table in the DB?
 
Well, you can select and drag multiple tables at a time from the server explorer to the Database Designer. So there's that. Or you can always generate your code from T-SQL itself. For example, running this query in Management Studio to generate some VB.Net code.

Code:
SELECT 'MyCommand.CommandText = "SELECT * FROM [' + TABLE_SCHEMA + '].[' + TABLE_NAME + ']"' + CHAR(13) + CHAR(10) +
'MyDataAdapter.FillSchema(MyDataSet, SchemaType.Mapped)'
FROM INFORMATION_SCHEMA.TABLES
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top