
USE [SodaDB]
go

-- if needed
-- DROP TABLE order_form_temp
-- DROP XML SCHEMA COLLECTION orderType
-- go

-- Load XML from a file
DECLARE @x XML
SET @x = (
SELECT * FROM OPENROWSET(
   BULK 'C:\Labs\L08_XML\Solution\XMLDataType\order.xsd',
           SINGLE_BLOB
) AS x
)

-- And use it to create an XML schema collection
CREATE XML SCHEMA COLLECTION orderType AS @x
go

-- XML SCHEMA COLLECTION CREATED

-- Now, alter the table so that it uses the XML Schema collection
-- It should allow only XML documents
CREATE TABLE order_form_temp (
 id INT IDENTITY PRIMARY KEY,
 order_form_xml XML(document orderType)
)
GO



