Solved

SQL Server Management Studio- setiing an Identity

Posted on 2010-11-11
6
545 Views
Last Modified: 2012-05-10
I've created a table but want to add an identity column to it.
How is this done through the management studio? (SQL Server 2008)
(The Identity specification is disabled and set to No for all columns).
Cheers
0
Comment
Question by:Spike_66
6 Comments
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 34111002
ALTER TABLE YourTable ALTER COLUMN Id IDENTITY (200,1)


0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 34111024
above assumes that the colum already exists.

If that isn't the case, then this will add a column and make it identity seed:

alter table yourTable
add  id int not null Identity(1,1)
0
 
LVL 1

Accepted Solution

by:
mribasu earned 125 total points
ID: 34111049
add any column int data type and then you can find indentity specification enbled but for varchar/bit  type column you can not find identity specification enble.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 7

Expert Comment

by:mkobrin
ID: 34111058
If the column you want to use already has data in it you will not be able to use it as an Identity column, you will need to create a new column, and it will have to be an int column and it may not allow nulls.
0
 

Author Closing Comment

by:Spike_66
ID: 34111072
Worked- although how do you do it through the table design properties?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34111152
you cannot ALTER a column to change from non-identity to identity.

you have to drop and recreate the column for that.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now