Primary Keys

  • Dwain Camps

    SSC Guru

    Points: 86893

    Comments posted to this topic are about the item Primary Keys


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • TomThomson

    SSC Guru

    Points: 104773

    Nice easy unambiguous question.

    A restful finish to to the week (for some), and a pleasant start to the week for others.

    Published a little before its time, I guess, as it's the day after tomorrow's question. πŸ˜›

    Tom

  • Ron McCullough

    SSC Guru

    Points: 63877

    L' Eomot InversΓ© (7/28/2012)


    Nice easy unambiguous question.

    A restful finish to to the week (for some), and a pleasant start to the week for others.

    Published a little before its time, I guess, as it's the day after tomorrow's question. πŸ˜›

    Nah just right if you use that unsupported command DBCC TIMEWARP

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • ralm

    Hall of Fame

    Points: 3156

    Index has the limitation of 16 key columns, primary key can be either clustered or non-clustered. So it can also have only 16 columns. I guessed the answer as above.

    πŸ™‚

    [font="Verdana"]Regards,
    Rals
    [/font].
  • Dwain Camps

    SSC Guru

    Points: 86893

    Tom, Bitbucket and Rals - Thanks for dropping by and giving it a shot.

    I believe that the limitation on columns participating in an INDEX is the same as for the primary key, so you were right to guess that Rals.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Koen Verbeeck

    SSC Guru

    Points: 258965

    Easy one for Monday, thanks!

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Sreepathi1987

    Default port

    Points: 1425

    Than you for the good week start.........!!!

  • Toreador

    SSChampion

    Points: 11259

    Got it wrong as there's no mention of a limit in the Primary Key or Create Table sections of BOL.

    Anyone who even approaches the limit should be sent on a training course anyway πŸ™‚

  • Jeff Moden

    SSC Guru

    Points: 997113

    I was pretty sure of the answer but went to check just to be absolutely sure because I've never gotten close to the limit. It just absolutely fascinates me that this little bit of very important "trivia" ISN'T covered under the constraints, primary key, or CREATE TABLE sections of BOL.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • This was removed by the editor as SPAM

  • Thomas Abraham

    SSChampion

    Points: 10761

    Jeff Moden (7/30/2012)


    I was pretty sure of the answer but went to check just to be absolutely sure because I've never gotten close to the limit. It just absolutely fascinates me that this little bit of very important "trivia" ISN'T covered under the constraints, primary key, or CREATE TABLE sections of BOL.

    Same reaction, both to the question and BOL. Also, wasn't there a recent question that was tangentially related to this? Something about large data types in an index?

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • (Bob Brown)

    SSCrazy

    Points: 2705

    Great question. Had to use MSDN to confirm my answer but will never forget it now.

  • Tock

    Default port

    Points: 1432

    +1

    Cheers,

    Steve

  • sestell1

    SSChampion

    Points: 10230

    Thanks for the question!

    This page shows the limit for primary key columns:

    http://msdn.microsoft.com/en-us/library/ms143432.aspx

  • asesoriabd

    Valued Member

    Points: 56

Viewing 15 posts - 1 through 15 (of 28 total)

You must be logged in to reply to this topic. Login to reply