Solved

TSQL syntax for adding a new column and making it a primay key as well.

Posted on 2011-03-10
2
302 Views
Last Modified: 2012-05-11
Hi, Does this look about right?
ALTER TABLE dbo.q_degree_type(
      ADD [DegreeTypeId] [int] IDENTITY(1,1) NOT NULL,
 CONSTRAINT [PK_degree_type] PRIMARY KEY CLUSTERED
(
      [DegreeTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
0
Comment
Question by:lapucca
2 Comments
 
LVL 15

Accepted Solution

by:
derekkromm earned 500 total points
ID: 35102834
close:

alter table dbo.q_degree_type add DegreeTypeId int identity(1,1) not null
constraint PK_degree_type primary key clustered (DegreeTypeId asc)
WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

0
 

Author Closing Comment

by:lapucca
ID: 35102954
Yeah, try to modify a generate script and got messed up with the parenthesis and the commas.  Thank you.
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

829 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