我正在尝试datetime2
在集合和表中使用 SQL Server XML SCHEMA 类型
CREATE XML SCHEMA COLLECTION [XmlValuesSchemaCollection_datetime2] AS
'<?xml version="1.0"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sql2008/SqlTypes.xsd"
attributeFormDefault="unqualified" elementFormDefault="qualified">
<xsd:element name="datetime2" type="xsd:datetime2"/>
</xsd:schema>';
GO
CREATE TABLE XmlValuesTable_datetime2 (
[uid] [int] IDENTITY PRIMARY KEY,
v XML(XmlValuesSchemaCollection_datetime2) NOT NULL
);
GO
INSERT INTO XmlValuesTable_datetime2 (v)
VALUES (N'<datetime2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">2014-06-18 06:39:05.190</datetime2>');
GO
但我有错误Reference to an undefined name 'datetime2' within namespace 'http://www.w3.org/2001/XMLSchema'
。与type="xsd:datetime2"
- 错误相同
Reference to an undefined name 'datetime2' within namespace 'http://schemas.microsoft.com/sqlserver/2004/sqltypes/sql2008/SqlTypes.xsd'
它应该以某种方式工作,https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/bb677236 (v=sql.105)?redirectedfrom=MSDN 中描述的类型但是不幸的是,我不知道出了什么问题。