Generate Schema (.xsd) from MS SQL Server Table
November 2nd, 2010 § Leave a Comment
I just had to extract the schema from a MS SQL server database table today and it was as easy as running this query:
DECLARE @schema xml
SET @schema = (SELECT * FROM TableName FOR XML AUTO, ELEMENTS, XMLSCHEMA(‘SchemaOutputName‘))
select @schema
Just save the output to a file with .xsd extension and there you have it.
Advertisement