?
Solved

SQL Server Management Studio- setiing an Identity

Posted on 2010-11-11
6
Medium Priority
?
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 29

Expert Comment

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


0
 
LVL 29

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 500 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
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 
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 143

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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

770 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