[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL Server Management Studio- setiing an Identity

Posted on 2010-11-11
6
Medium Priority
?
592 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 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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
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

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
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.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

834 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