Hi,

What would be the shortest way to generate an XSD for a SQL table?

Thanks,
Alan

Re: XSD From SQL Table by C

C
Sun Jul 25 12:57:05 CDT 2004

The way I go about quickly building schemas is to let the framework do the
work. What I do is setup a DataAdapter as if I was going to populate a
DataSet with data. But instead of calling .Fill() I call .FillSchema().
Then when the DataSet is just the way I like it I write it to a file using
DataSet.WriteXmlSchema().

For example:
// code to setup connection, etc.
DataSet ds = new DataSet("mySchema"); // make sure you give it a good
proper name
SqlDataAdapter da = new SqlDataAdapter("select * from orders", conn);

da.FillSchema(ds, System.Data.SchemaType.Source, "orders"); // again
give a good proper name here

// continue building your schema adding more tables and relationships

// write the schema to a file
ds.WriteXmlSchema("MySchema.schema");

HTH,

C Addison Ritchie, MCSD
Ritch Consulting, Inc.



Re: XSD From SQL Table by Miha

Miha
Sun Jul 25 13:54:51 CDT 2004

Hi Ali.M,

If you are talking about design time you have to check out CodeSmith (free
tool) and my (or any other) template for generating strong typed dataset
schema.
CodeSmith: www.ericjsmith.net/codesmith
Dataset template:
http://www.rthand.com/default.aspx?Page=2&SubPage=1#5
It generates one or more table schemas within a mouse click.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Ali.M" <Hate@Spam.com> wrote in message
news:eqwrcsmcEHA.3300@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> What would be the shortest way to generate an XSD for a SQL table?
>
> Thanks,
> Alan
>
>