我正在尝试将记录从 table1 填充到 table2。table1 有三列,没有主键。Table2 具有三个相同的列,其中一个标识列作为主键。以下是我的查询和定义。但不知何故,我得到了一个错误,无法将值 NULL 插入列 'notes_id',表 'table1; 列不允许空值。插入失败。该语句已终止。我想念什么?
CREATE TABLE [dbo].[table1](
[notes_id] [int] NOT NULL,
[acty_id] [varchar](80) NOT NULL,
[notes_datetime] [datetime] NOT NULL,
[notes_data] [nvarchar](max) NULL,
CONSTRAINT [PK_tblSRMNotes] PRIMARY KEY CLUSTERED
(
[notes_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[table2](
[acty_id] [varchar](80) NOT NULL,
[notes_datetime] [datetime] NOT NULL,
[notes_data] [nvarchar](max) NULL
) ON [PRIMARY]
insert into table1(acty_id, notes_datetime, notes_data)
select s.acty_id, s.notes_datetime, s.notes_data
from table2 s