locked
Import XSD into SQL RRS feed

  • Question

  • Looking for guidance on importing XSD into SQL using SSMS.  Original thought was that it was similar to importing other types of data (i.e. excel, flat files, etc). 

    What are the options/steps to follow to create database tables using XSD?

    Thanks.

    Tuesday, February 16, 2010 7:44 PM

Answers

  • You can import a file into a table:

    CREATE TABLE #temp (
    dt		DATETIME,
    col1	XML
    )
    
    /*Use the OPENROWSET and BULK load to load an xml file into 
    the table.  GETDATE() is used to populate the first column*/
    INSERT #temp
    SELECT GETDATE(), *
     FROM OPENROWSET(BULK 'C:\Employees.xsd',
       SINGLE_BLOB) AS x;
    
    SELECT *
    FROM #temp
    
    DROP TABLE #temp
    
    This will import the xsd file into an xml column, but there currently is no native support in SSMS to create a table using xml.
    David Dye
    Tuesday, February 16, 2010 7:55 PM