Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Reinsert data with old Ident column value

Author  Topic 

cornall
Posting Yak Master

148 Posts

Posted - 2009-03-20 : 07:49:32
Hi,

I archived a bunch of data out of a database and now there is a requirement to restore some records.

These records have forign key relationships with each table involved.

Is there anyway to reinsert them using their old identity column values which I have in the backup.

e.g.

Original Data

1 sometext
2 sometext
3 sometext
4 sometext
5 sometext

After Arive

1 sometext
2 sometext
5 sometext

After normal reinsert

1 sometext
2 sometext
5 sometext
6 sometext
7 sometext

What I want to get back to

1 sometext
2 sometext
3 sometext
4 sometext
5 sometext

Where 1,2,3,4,5 is my auto incrementing identity column.

Cheers Dave



sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-20 : 08:09:30
You can insert to identity column by setting SET IDENTITY_INSERT ON.
Go to Top of Page

cornall
Posting Yak Master

148 Posts

Posted - 2009-03-20 : 08:10:16
Works perfectly thanks
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-20 : 08:11:16
np
Go to Top of Page
   

- Advertisement -