SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Primary Keys


Primary Keys

Author
Message
Jamie-2229
Jamie-2229
SSCertifiable
SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)

Group: General Forum Members
Points: 5553 Visits: 862
When are Kim and Paul coming to Atlanta... this sounds like a great lecture.

Jamie
Paul White
Paul White
SSC Guru
SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)

Group: General Forum Members
Points: 79512 Visits: 11400
Good question, but the wording could have been clearer. Nice easy points though - thanks.



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
C.K.Shaiju
C.K.Shaiju
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2338 Visits: 711
Hi Hugo,

The 3rd and 6th options seems similar.

Shaiju C.K.

_____________________________________________
One ounce of practice is more important than tonnes of dreams
Hugo Kornelis
Hugo Kornelis
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34277 Visits: 13111
C.K.Shaiju (4/1/2010)
Hi Hugo,

The 3rd and 6th options seems similar.

Shaiju C.K.

You are right! Thanks for pointing it out. The sixth option should have read "A clustered index exists ..." instead of "No clustered index exists ..."

I have edited my post to prevent future confusion.


Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
parthenitin
parthenitin
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1136 Visits: 63
When we creates the primary key it alwas enforce to create as Clustured.
how it will enforce to create as NonClustered.

Please Can u tell me.
Paul White
Paul White
SSC Guru
SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)

Group: General Forum Members
Points: 79512 Visits: 11400
parthenitin (4/3/2010)
When we creates the primary key it alwas enforce to create as Clustured.
how it will enforce to create as NonClustered.
Please Can u tell me.

Use the NONCLUSTERED keyword.
See Creating and Modifying PRIMARY KEY Constraints

Example:

DECLARE @Table
TABLE (
column1 INTEGER NOT NULL
PRIMARY KEY NONCLUSTERED
);





Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
Hugo Kornelis
Hugo Kornelis
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34277 Visits: 13111
parthenitin (4/3/2010)
When we creates the primary key it alwas enforce to create as Clustured.
how it will enforce to create as NonClustered.

Please Can u tell me.

In addition to the reply by Paul -- if there is already a clutered index on the table, then the index for the primary key will also default to nonclustered.


Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Kimberly L. Tripp
Kimberly L. Tripp
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 62
Thanks Hugo. That was the main one (and point) I was making.

Often people use scripts to create objects but there are strange cases where multiple developers working on the same project creates... er... "issues" and the indexes aren't quite as consistent as expected. Constraints are often created via scripts but often as standalone scripts (not always as part of the table's create) and sometimes problems can occur when there are too many cooks in the kitchen. ;-)

Cheers!
Kimberly L. Tripp
SQL Server MVP, Microsoft Regional Director
blog: www.SQLskills.com/blogs/Kimberly
twitter: www.twitter.com/KimberlyLTripp
khullargirish02
khullargirish02
SSC-Addicted
SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)

Group: General Forum Members
Points: 453 Visits: 126
False, if a clustered index already exists, DB will enforce the Primary Key constraint with a nonclustered index
khullargirish02
khullargirish02
SSC-Addicted
SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)SSC-Addicted (453 reputation)

Group: General Forum Members
Points: 453 Visits: 126
if a clustered index already exists, SQL Server will enforce the Primary Key constraint with a nonclustered index
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search