Job Lot said:
how can persist schema for a sql server table into an xml file from .net
application?
There are probably many ways to do this. Some quick overviews and then I can
give you more details.
1. Sql Server can provide XML based information that you can use
SqlXmlCommand. I use this to create an XML schema of my complete database
from which I apply an XLST to and generate code from this. This is used when
I know nothing about my database at all, not even a table name.
2. If you know a table name it has some data then you can SELECT TOP 1 *
FROM TableName and then while reading the first row using SqlDataReader you
can get the field count and then get the column name and column type and
create an XML file from this information.
3. I believe that if you have a strongly typed dataset then you can get
schema information but then if you already have the typed dataset then you
probably already have the information you need.
The best answer is probably where and how the information is being used,
e.g. during development, in a production environment, is the table
information dynamic or can you setup your application ahead of time with a
typed dataset.
PS