Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

Primary Keys Expand / Collapse
Author
Message
Posted Sunday, March 21, 2010 8:04 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, April 11, 2014 1:51 PM
Points: 2,628, Visits: 760
When are Kim and Paul coming to Atlanta... this sounds like a great lecture.

Jamie
Post #887070
Posted Tuesday, March 30, 2010 8:13 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 5:04 PM
Points: 11,168, Visits: 10,939
Good question, but the wording could have been clearer. Nice easy points though - thanks.



Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #892804
Posted Thursday, April 01, 2010 1:18 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 5:41 AM
Points: 196, Visits: 642
Hi Hugo,

The 3rd and 6th options seems similar.

Shaiju C.K.


_____________________________________________
One ounce of practice is more important than tonnes of dreams
Post #894476
Posted Thursday, April 01, 2010 1:33 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:48 PM
Points: 5,802, Visits: 8,019
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
Post #894481
Posted Saturday, April 03, 2010 2:39 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, December 03, 2013 1:16 AM
Points: 957, Visits: 62
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.
Post #896178
Posted Saturday, April 03, 2010 2:53 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 5:04 PM
Points: 11,168, Visits: 10,939
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
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #896181
Posted Saturday, April 03, 2010 6:29 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:48 PM
Points: 5,802, Visits: 8,019
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
Post #896218
Posted Sunday, April 04, 2010 2:21 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 01, 2014 2:15 PM
Points: 27, Visits: 54
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
Post #896469
Posted Friday, May 27, 2011 3:54 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, April 10, 2014 9:51 PM
Points: 371, Visits: 111
False, if a clustered index already exists, DB will enforce the Primary Key constraint with a nonclustered index
Post #1116092
Posted Friday, May 27, 2011 3:55 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, April 10, 2014 9:51 PM
Points: 371, Visits: 111
if a clustered index already exists, SQL Server will enforce the Primary Key constraint with a nonclustered index
Post #1116093
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse