I am trying to restore the visits from a backup database to the live database. I am deleting all the visits for a client then restoring the visits from the backup. (client screwed things up). BUT, getting an error: Violation of PRIMARY KEY constraint 'PK_Visit'. Cannot insert duplicate key in object 'dbo.visit'.
It is as if the visit records were still there. Is there a way to PACK the table so the deleted visits are completely gone?
delete from [LiveDB].[dbo].visit where clientno= 100
select * into #tmpVisit from [BackupDB].[dbo].[visit] where clientno= 100
insert into [LiveDB].[dbo].[visit] select * from #tmpvisit