SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 auto-incremented column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mathmax
Yak Posting Veteran

France
95 Posts

Posted - 12/06/2006 :  16:04:55  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Australia
1242 Posts

Posted - 12/06/2006 :  16:10:59  Show Profile  Visit timmy's Homepage  Reply with Quote
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

France
95 Posts

Posted - 12/06/2006 :  16:24:23  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Australia
1242 Posts

Posted - 12/06/2006 :  19:16:36  Show Profile  Visit timmy's Homepage  Reply with Quote
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

France
95 Posts

Posted - 12/06/2006 :  21:26:12  Show Profile  Reply with Quote
thank you timmy. Perhaps I have to try Enterprise Manager...
Go to Top of Page

timmy
Flowing Fount of Yak Knowledge

Australia
1242 Posts

Posted - 12/06/2006 :  22:29:12  Show Profile  Visit timmy's Homepage  Reply with Quote
Good idea.....
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 Posts

Posted - 12/07/2006 :  02:57:18  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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 - 12/07/2006 :  09:51:50  Show Profile  Reply with Quote
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

Sweden
30282 Posts

Posted - 12/07/2006 :  09:55:04  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Does?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000