Solved

SQL Server Management Studio- setiing an Identity

Posted on 2010-11-11
6
547 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
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.

839 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