Solved

SQL Server Management Studio- setiing an Identity

Posted on 2010-11-11
6
551 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 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

696 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