IDENTITY_INSERT 我遇到了一个奇怪的问题并且不知所措。谁能看到我错过了什么?
I'm having a weird issue with IDENTITY_INSERT & am at a loss. Can anyone see what I'm missing?
我在尝试执行以下语句时遇到错误,抱怨必须打开 IDENTITY_INSERT 才能进行插入,但我正在打开它。
SET IDENTITY_INSERT Thompson_GDM.dbo.employees ON
GO
INSERT INTO Thompson_GDM.dbo.employees
SELECT [EmployeeId],
[AssignmentId],
[more columns...]
FROM TMLAVSQLBIS.ThompsonMachinery.dbo.Employees;
GO
SET IDENTITY_INSERT Thompson_GDM.dbo.employees OFF
go
错误消息是“table 'Thompson_GDM.dbo.employees' 中标识列的显式值只能在使用列列表且 IDENTITY_INSERT 为 ON 时指定。”
如您所见,我使用的是列列表,它与 table 布局相匹配。我检查了好几次,确实匹配
在 INSERT INTO 之后(SELECT 之前)需要一个列列表:
SET IDENTITY_INSERT Thompson_GDM.dbo.employees ON
GO
INSERT INTO Thompson_GDM.dbo.employees([EmployeeId],
[AssignmentId],
[more columns...] )
SELECT [EmployeeId],
[AssignmentId],
[more columns...]
FROM TMLAVSQLBIS.ThompsonMachinery.dbo.Employees;
GO
SET IDENTITY_INSERT Thompson_GDM.dbo.employees OFF
go
显然“更多列”是实际列
我在尝试执行以下语句时遇到错误,抱怨必须打开 IDENTITY_INSERT 才能进行插入,但我正在打开它。
SET IDENTITY_INSERT Thompson_GDM.dbo.employees ON
GO
INSERT INTO Thompson_GDM.dbo.employees
SELECT [EmployeeId],
[AssignmentId],
[more columns...]
FROM TMLAVSQLBIS.ThompsonMachinery.dbo.Employees;
GO
SET IDENTITY_INSERT Thompson_GDM.dbo.employees OFF
go
错误消息是“table 'Thompson_GDM.dbo.employees' 中标识列的显式值只能在使用列列表且 IDENTITY_INSERT 为 ON 时指定。”
如您所见,我使用的是列列表,它与 table 布局相匹配。我检查了好几次,确实匹配
在 INSERT INTO 之后(SELECT 之前)需要一个列列表:
SET IDENTITY_INSERT Thompson_GDM.dbo.employees ON
GO
INSERT INTO Thompson_GDM.dbo.employees([EmployeeId],
[AssignmentId],
[more columns...] )
SELECT [EmployeeId],
[AssignmentId],
[more columns...]
FROM TMLAVSQLBIS.ThompsonMachinery.dbo.Employees;
GO
SET IDENTITY_INSERT Thompson_GDM.dbo.employees OFF
go
显然“更多列”是实际列