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


Primary Keys


Primary Keys

Author
Message
Jamie-2229
Jamie-2229
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

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

Jamie
Paul White
Paul White
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: General Forum Members
Points: 35186 Visits: 11359
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
SSC Eights!
SSC Eights! (972 reputation)SSC Eights! (972 reputation)SSC Eights! (972 reputation)SSC Eights! (972 reputation)SSC Eights! (972 reputation)SSC Eights! (972 reputation)SSC Eights! (972 reputation)SSC Eights! (972 reputation)

Group: General Forum Members
Points: 972 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
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18683 Visits: 12426
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 MVP
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: 1098 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-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: General Forum Members
Points: 35186 Visits: 11359
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
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18683 Visits: 12426
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 MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Kimberly L. Tripp
Kimberly L. Tripp
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 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 (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)

Group: General Forum Members
Points: 415 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 (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)

Group: General Forum Members
Points: 415 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