Dumb primary key question

  • So I've got this database with a type of key I've never seen before. I don't even know what to call it, so I can't really search for it (though I have tried). It's a bigint and each key is unique across the database, but it's not a GUID and it's not a natural key. And it's not like typical auto-generated keys, with each table having 1, 2, 3, etc, because each key is unique. My question is, how do I duplicate this? Is there a function in SQL somewhere that I'm not aware of? I wonder if the software generating the data is doing this?

    I posted this in the 2008 forum because that's what I'm working with.

    Thanks in advance for any help.

    Here's a sample:

    Key TableName

    1229096194025 TableA

    1229096194026 TableA

    1229096194027 TableB

    1229096194028 TableC

    1229096194029 TableD

    1229096194030 TableE

    1229096194031 TableF

    1229096194032 TableG

    1229096194041 TableH

    1229096194042 TableA

  • kdbarrett (10/6/2010)


    Is there a function in SQL somewhere that I'm not aware of? I wonder if the software generating the data is doing this?

    Nope, and I believe it will be too 🙂

    You'll probably find a master table that keeps track of the greatest value.

  • I would think that there is some function or method in your software that generates this.

    Is this one column? With both the number and the table in it? Or two columns? I've seen this implemented as two columns before.

  • Thanks for your replies and yes, I'm thinking it is the software doing this.

    The example came from a query I wrote to look at all the PKs in the database with the tablename next to the value. Just a bunch of simple selects/unions on the PKs with the tablename, all ordered by the PK. I suspected this odd key behavior but I wanted to actually see it.

Viewing 4 posts - 1 through 3 (of 3 total)

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