如何在SQL Server的nvarchar列中输入值'NULL'?

VKa*_*hik 4 sql t-sql sql-server

我需要将文字值'NULL'作为默认值插入nvarchar列.但是当我插入记录时,默认值为db NULL而不是文字'NULL'.谁能告诉我哪里出错了?

小智 5

所以你想要插入实际的"NULL"字符串?尝试这样的事情:

create table NullTable
(
    nvarchar(100) not null default 'NULL',
    .... -- your other fields
)
Run Code Online (Sandbox Code Playgroud)

编辑: 这是一个完整的解决方案

create table InsertNull
(
    Nullfield nvarchar(100) not null default 'NULL',
    someint int not null
)
go

insert into insertnull(someint)
select 20

select *
from InsertNull
Run Code Online (Sandbox Code Playgroud)