Solved

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

Posted on 2011-03-10
2
301 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add different cell to otherwise similiar row 4 37
Help Required 3 89
Query Syntax 17 31
Sql Server group by 10 23
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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 …

813 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

10 Experts available now in Live!

Get 1:1 Help Now