Solved

alter is identity

Posted on 2013-11-29
4
333 Views
Last Modified: 2013-12-13
How can I alter is identity from NO to Yes from tsql?  We have sql 2008 server R2.
table.jpg
0
Comment
Question by:VBdotnet2005
  • 2
4 Comments
 
LVL 9

Expert Comment

by:guswebb
ID: 39686021
When you click on 'No' (to the right of Is Identity)  do you not get a drop-down menu allowing you to select Yes?
0
 
LVL 9

Expert Comment

by:guswebb
ID: 39686033
If this is a pre-existing column you can't alter it. You need to create a new column and set Is Identity at that point, then drop your current column.
0
 

Author Comment

by:VBdotnet2005
ID: 39690395
Under Identity Specification, I want to set Is Identity to Yes in TSQL. I know how to do it in design. This is a brand new table.

Link
0
 
LVL 1

Accepted Solution

by:
YaraKnight earned 500 total points
ID: 39691320
In a new query window where Names is your table name, and 'Column' is your desired column name:

Alter Table Names
Add Id_new Int Identity(1, 1)
Go

Alter Table Names Drop Column ID
Go

Exec sp_rename 'Names.Id_new', 'ID', 'Column'
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

821 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