Solved

alter is identity

Posted on 2013-11-29
4
328 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

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

Suggested Solutions

Title # Comments Views Activity
Sql server function help 15 30
Query Syntax 17 34
MS SQL / SQL Server Native Client -- how to prevent seeing other servers? 2 23
performance query 4 22
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

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