define composite primary key with more than 900 bytes

  • I have a situaton where in i need to define unique combination of some of the columns I tried defined it using composite primary key. But I have more than 70 columns and this is exceeding 900 bytes. Anybody has any solution. Please let me know.

  • anbillava (4/15/2010)


    I have a situaton where in i need to define unique combination of some of the columns I tried defined it using composite primary key. But I have more than 70 columns and this is exceeding 900 bytes. Anybody has any solution. Please let me know.

    Why do you need a composite key made up of more than 70 columns? Something doesn't sound right here.

  • I have situation where in if user enters same data then i need throw him a error message depending up on the primary key violation. Each row in the table should be unique against the other. Any other solution is appreciated.

    Thanks

  • You could assign a unique key to a checksum of all of the columns.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thanks for the reply.

    CAn you please tell me how to do that ?

  • Try this article.

    http://www.mssqltips.com/tip.asp?tip=1023

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • So what you are saying is that in this particular table, there is no candidate key that could serve as a primary key?

  • Seems to me that this article may also help, http://qa.sqlservercentral.com/articles/Data+Warehouse/69679/.

  • Is that link tells me about defining unique key for checksum of mulitple columns.

    I did not understand how that works ?

    Do i need to check table for the duplicate row using checksum function or blind entry of new data which is duplicate will throw a vilolation ?

  • No. There is no candidate key which can replace this.

  • Actually, anything we tell you is simply a shot in the dark. We have no idea what you are trying to do, or what type of data is being stored in this (currently) nebulus table in which the primary key appears to be every column in the table.

    Where and how is the data being inserted into the table? Is the data load from a file or entry from an application?

  • CAn anybody help me in defining checksum column ?

    MAny Thanks

  • Have you looked up CHECKSUM in BOL (Books Online)? If not, try this.

  • Hi all,

    I am able to define checksum column and do the job .

    Thanks to all.

    Anand

  • You're welcome. Hope it works out for you.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

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

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