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
 General SQL Server Forums
 New to SQL Server Programming
 change/issue a new Id for IDENTITY field

Author  Topic 

igor22
Starting Member

18 Posts

Posted - 2007-08-13 : 17:59:06
Hey guys,

I have a content table with a field "[Content_ID] [int] IDENTITY(1,1) NOT NULL". I need to change the content id of some of the content because it was leaked into an xml feed and we want to stop people from accessing the content, is it possible to change/issue a new Id for a field that is set as "IDENTITY"?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-13 : 18:09:12
You can do a

INSERT INTO ....
SELECT ....
FROM ....
WHERE ...


followed by a DELETE of old Id's. Basically copy the same data back to the table, SQL Server will assign new Id's , then delete old data.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2007-08-13 : 22:44:49
you can also set identity OFF for the table and then do an update statement. Remember to set identity ON when you're done.
Go to Top of Page
   

- Advertisement -