从MS SQL数据库获取XML模式 [英] Getting XML Schema from MS SQL Database
本文介绍了从MS SQL数据库获取XML模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用.Net和C#以编程方式生成数据库的XML模式?我想研究NDbUnit,但对于大数据库,手动制作一个模式是不可行的吗?
Is it possible to generate a XML Schema of a Database programatically with .Net and C#? I want to look into NDbUnit but for big databases it would not really be feasible to make a Schema manually?
推荐答案
是否可以从数据库生成XML
模式? p>
Is it possible to generate a XML Schema from a Database?
当然, XMLSpy 可以从数据库生成XML模式。
It sure is, XMLSpy can generate XML Schema from a database.
有另一种方式,但我从未测试过:
create table Person
(
Age int not NULL check( Age > 0) ,
Height numeric(10,2) not NULL check( Height > 5),
Gender varchar(5) not null check( Gender in ('M', 'F', 'O')),
BirthDate datetime null,
)
DECLARE @schema xml
SET @schema = (SELECT * FROM Person FOR XML AUTO, ELEMENTS, XMLSCHEMA('PersonSchema'))
select @schema
这篇关于从MS SQL数据库获取XML模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文