Generate XML Schema from SQL Server 2005


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Generate XML Schema from SQL Server 2005

  1. #1
    Join Date
    Aug 2008
    Posts
    33

    Generate XML Schema from SQL Server 2005

    Greetings All;

    I'm wondering if anyone knows how to generate an XML Schema from a database in SQL Server 2005.

    I'm looking to take data from an HL7 feed (I have the schema for that already) and plug that into SQL Server using BizTalk 2006.

    I've been searching this but haven't found anything.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    I found this. Does it help?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Actually, this one looks like it might be even better for you.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Aug 2008
    Posts
    33
    Hey Thanks!
    This is pretty complicated stuff. I've posted this question to several different places and got a lot of different answers.
    Couldn't get into the first one as they didn't send me a confirmation email. The second one would work, but if I understand it only if I was using the XML within SQL Server.

    But I found this:

    Code:
    Declare @schema xml
    Set @schema = (SELECT * From dbo.PatientIndex FOR XML AUTO, ELEMENTS,
    XMLSCHEMA('PISchema'))
    select @schema
    OUTPUT:
    Its important to run this in Management Studio as a Database Engine Query.
    In the drop down list, select the database, click "Execute" and voila!

    Thanks for the assist!
    Last edited by Hack; 09-18-2008 at 12:02 PM. Reason: Fixed Code Tags

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    For this first one, the URL is http://www.sswug.org/see/24588 - I don't have a problem getting to it.

    I don't have 2005 here so I can't test....did you run that code to see what happens.

    (PS: I fixed your [code]your code goes here[/code] tags. You forgot the / on the ending [code] tag. )
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  6. #6
    Join Date
    Apr 2012
    Posts
    1

    A little tweak...

    This will give you the schema only:

    Code:
    Declare @schema xml
    Set @schema = (SELECT top 0 * From dbo.Students FOR XML AUTO, XMLSCHEMA('StudentSchema'))
    select @schema
    OUTPUT:

Similar Threads

  1. Replies: 16
    Last Post: 08-22-2007, 07:31 AM
  2. Replies: 1
    Last Post: 05-23-2007, 12:53 PM
  3. Replies: 0
    Last Post: 12-20-2006, 09:50 AM
  4. XML Generation from SQL Server
    By Madhu in forum Database
    Replies: 0
    Last Post: 07-14-2003, 10:26 AM
  5. Returning XML from SQL Server
    By Mike in forum authorevents.vieira
    Replies: 3
    Last Post: 01-23-2001, 10:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center