Solved

alter is identity

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now