我试图运行查询并获得此错误代码...
insert ScvmmVirtualMachines(VmId, ScvmmServer, VmName, ComputerName, Description, VmAdditions, OS, IsHighlyAvailable, CpuCount, MemoryMB, TotalDiskSizeByte, FirstDiscoveredUtc, LastUpdatedUtc, IsCurrentRecord, ScvmmHost_ScvmmHostName, ScvmmVmId, VmLocation)
select
l.VmId,
l.ScvmmServer,
l.VmName,
l.ComputerName,
l.Description,
l.VmAdditions,
l.OS,
l.IsHighlyAvailable,
l.CpuCount,
l.MemoryMB,
l.TotalDiskSizeByte,
l.DateExtracted,
l.DateExtracted,
1,
l.ScvmmHost_ScvmmHostName,
l.ScvmmVmId,
l.VmLocation
from
data1 d
inner join
LoadScvmmVirtualMachines l
on d.VmId = l.VmId
and d.maxDate = l.DateExtracted;
if @DeleteLoadData = 1
begin
delete
from
LoadScvmmVirtualMachines
where
DateExtracted <= @MaxDate
end
end
-- Flag old records as no longer current
update
ScvmmVirtualMachines
set
IsCurrentRecord =
(
case
when
LastUpdatedUtc < @IsCurrentThreshold
then
0
else
1
end
)
where
IsCurrentRecord <> (
case
when
LastUpdatedUtc < @IsCurrentThreshold
then
0
else
1
end
) -- Set the OS for all scvmmVirtualMachines
update
ScvmmVirtualMachines
set
OperatingSystemId = o.OperatingSystemId
from
ScvmmVirtualMachines v
inner join
OperatingSystemNames o
on v.OS = o.OperatingSystemNameId
set
@MaxRecId = null
select
@MaxRecId = max(RecId)
from
loadADComputers
20195617:032323:DSP116:信息:运行存储过程ProcessLoadData 从加载表加载数据。 20195617:032323:DSP116:错误: 运行存储过程ProcessLoadData时出错。错误:异常 使用“ 0”参数调用“ ExecuteNonQuery”:“违反PRIMARY 密钥约束'PK_dbo.VirtualMachines'。无法插入重复密钥 在对象“ dbo.VirtualMachines”中。重复键值为(2209836)。 该语句已终止。“ 20195617:032323:DSP116:信息:
完成错误!