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
 auto-incremented column

Author  Topic 

mathmax
Yak Posting Veteran

95 Posts

Posted - 2006-12-06 : 16:04:55
Hello,
I have a column that is not auto-incremented. I would like to make it auto-incremented. For the moment, the only solution I found is to delete my column and to add a new auto-incremented column. The problem is I cannot delete it without deleting dependencies on it... So is there a solution to make an existing column auto-incremented or is it necessary to a create a new column ?

Thank you in advance for your help.

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-12-06 : 16:10:59
If you do this from Enterprise Manager it will do all the dependencies stuff for you (if required). Just try opening the table in design view and changing the IDENTITY property and see what happens (obviously backup before trying this...)

HTH,

Tim
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2006-12-06 : 16:24:23
I use SQL manager 2005. The IDENTITY property is disabled. I cannot modify it. I can change its value only when I create a new column.
Go to Top of Page

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-12-06 : 19:16:36
OK then. I would:
-script out your dependencies
-delete the dependencies
-create a new temporary table of identical structure but has your column as an IDENTITY
-copy across your data
-delete the existing table
-rename the temporary table back to the original name

This is basically what Enterprise Manager does when you try and change a column to an IDENTITY column. You could also add a new IDENTITY column (provided your table doesn't already have one), but I suspect that you'll have to modify the dependant code to point to the new column.

HTH,

Tim
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2006-12-06 : 21:26:12
thank you timmy. Perhaps I have to try Enterprise Manager...
Go to Top of Page

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-12-06 : 22:29:12
Good idea.....
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-07 : 02:57:18
Do Enterprise Manager work on SQL 2005 databases?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-12-07 : 09:51:50
quote:
Originally posted by Peso

Do Enterprise Manager work on SQL 2005 databases?


Peter Larsson
Helsingborg, Sweden



Do?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-07 : 09:55:04
Does?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -