我在为存储过程执行作业时遇到问题,它返回一个错误,我可以将数据插入表中
当 IDENTITY_INSERT 设置为 OFF 时,无法在表“TagMovementTable_temp”中插入标识列的显式值。[SQLSTATE 23000](错误 544)。步骤失败。,00:00:00,16,544,,,,0
这是我的程序,我已经设置IDENTITY_INSERT
为 ON,我不知道该怎么办,请帮助和想法?
SET IDENTITY_INSERT Backup_movment.dbo.TagMovementTable_temp ON
go
ALTER procedure [dbo].[DeleteTagData]
as
begin
insert into Backup_movment.dbo.TagMovementTable_temp([ID]
,[TagID]
,[AntennaID]
,[RSSI]
,[Timestamp]
,[TagData]
,[ZoneCoordinateGroupID]
,[DBTimeStamp]
,[BatteryStatus]
,[Longitude]
,[Latitude]
,[Accuracy])
select
[ID]
,[TagID]
,[AntennaID]
,[RSSI]
,[Timestamp]
,[TagData]
,[ZoneCoordinateGroupID]
,[DBTimeStamp]
,[BatteryStatus]
,[Longitude]
,[Latitude]
,[Accuracy]
FROM
[TrailBlazerNG].[dbo].[TagMovementTable]
where not exists (select 1
from Backup_movment.dbo.TagMovementTable_temp
where Backup_movment.dbo.TagMovementTable_temp.ID = [TrailBlazerNG].[dbo].[TagMovementTable].ID )
if not exists(select top 1 * from ZoneTable where EmergencyMode=1)
begin
delete top(10000) from TagMovementTable where [DBTimeStamp]<DATEADD(hh,-24,getdate())
end
Delete from tagstrongestpingdatatable where [dbtimestamp] < dateadd(hh,-4,getdate())
Delete from tagrawdatatable where [dbtimestamp] < dateadd(hh,-1,getdate())
end