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
 how do I drop auto increment?

Author  Topic 

kifeda
Posting Yak Master

136 Posts

Posted - 2007-01-19 : 10:24:17
I have a field, userid, that somehow has the auto increment feature on it and I just want it to me a regular int field. How do i change it?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-19 : 10:34:03
You open the table's design in Enterprise Manger and click the UserID column.
In the properties below, uncheck IDENTITY.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

kifeda
Posting Yak Master

136 Posts

Posted - 2007-01-19 : 10:44:03
yes, but I have do do it in sql because I have the database on a hosting site.
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-01-19 : 10:45:26
Use ALTER TABLE to add a new column, run an UPDATE to copy the existing values from the existing identity column to the new column, use ALTER TABLE to drop the identity column, use sp_rename to rename the new column to the name of the original identity column.

Alternatively, if the table isn't huge, create a new table with the exact same structure as the existing table, but don't make the current identity column an identity column. Use INSERT ... SELECT to copy all the data from the existing table to the new table, then drop the existing table and rename the new one with sp_rename - I think this is how Enterprise Manager (2000) or Management Studio (2005) will do it. You could also just edit the table in Enterprise Manager or Management Studio and it will do that for you.
Go to Top of Page

kifeda
Posting Yak Master

136 Posts

Posted - 2007-01-19 : 11:29:13
thank you
Go to Top of Page
   

- Advertisement -