一个简单的例子:
CREATE TABLE People (
personID int not null
, name nvarchar(50) not null
, addrLine1 nvarchar(50) null
, addrLine2 nvarchar(50) null
, suburb nvarchar(30) not null
, xmlRawInput ntext not null
, xmlRawOutput ntext null
)
GO
INSERT People (
personID
, name
, addrLine1
, addrLine2
, suburb
, xmlRawInput
, xmlRawOutput
)
SELECT
101 AS personID
, 'george benson' AS name
, '123 help st' AS addrLine1
, NULL AS addrLine2
, 'los angeles' AS suburb
, '<example>record<example>' AS xmlRawInput
, 'I LOVE MICROSOFT' AS xmlRawOutput
GO
这很好用;注意 Null 可以很容易地插入到 addrLine2 列中;但是,如果我在 ntext 列上将 'I Love Microsoft' 更改为 NULL,我会收到以下错误:不支持转换。[要转换的类型(如果知道)= int,要转换的类型(如果知道)= ntext ]
以下插入失败;有任何想法吗?我使用的是 CE 版本 3.5.8080.0。
INSERT People (
personID
, name
, addrLine1
, addrLine2
, suburb
, xmlRawInput
, xmlRawOutput
)
SELECT
101 AS personID
, 'george benson' AS name
, '123 help st' AS addrLine1
, NULL AS addrLine2
, 'los angeles' AS suburb
, '<example>record<example>' AS xmlRawInput
, NULL AS xmlRawOutput
GO