Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Generate Unique ID

Generate Unique ID

Scheduled Pinned Locked Moved Database
databasesql-serversysadmintutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mcgann
    wrote on last edited by
    #1

    I'm tryin to create a unique id for each row in the database(SQL SERVER), I don't want to use the standard convention of uniqueidentifer. but to create my own which takes an abbreviation say 'pm' adds the year '06' and finally adds the next row number in sequence. eg. id = 'pm' + '06' + '0001' Has anyone any ideas of how to do this. I have something working but it's not entirely correct. gfhg

    F 1 Reply Last reply
    0
    • M mcgann

      I'm tryin to create a unique id for each row in the database(SQL SERVER), I don't want to use the standard convention of uniqueidentifer. but to create my own which takes an abbreviation say 'pm' adds the year '06' and finally adds the next row number in sequence. eg. id = 'pm' + '06' + '0001' Has anyone any ideas of how to do this. I have something working but it's not entirely correct. gfhg

      F Offline
      F Offline
      Farhan Noor Qureshi
      wrote on last edited by
      #2

      You could use a combination key, of, say: 1. PK_ID int IDENTITY (1, 1) NOT NULL 2. Abbreviation_of_whatever varchar(10) NOT NULL 3. Year int NOT NULL :~ Farhan Noor Qureshi if (this == this) thow this;

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups