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. Can we restrict the number of maximum records inserted in a particular table?

Can we restrict the number of maximum records inserted in a particular table?

Scheduled Pinned Locked Moved Database
databasehelptutorialquestion
8 Posts 4 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.
  • R Offline
    R Offline
    Rocky
    wrote on last edited by
    #1

    hi everyone, I've a table in which the primary key needs to be a six digit number and must start from 1, so for that I made it an identity key (100001,1) but the problem is that I can't figure out how to restrict this to not exceed 199999 I'm using Sql Express 2005 as the Database. As far as I've seen while googling it out. There's no obvious way to do that. Can anyone comment on that plz? Thanks in advance

    Rocky Success is a ladder which you can't climb with your hands in your pockets.

    K N 2 Replies Last reply
    0
    • R Rocky

      hi everyone, I've a table in which the primary key needs to be a six digit number and must start from 1, so for that I made it an identity key (100001,1) but the problem is that I can't figure out how to restrict this to not exceed 199999 I'm using Sql Express 2005 as the Database. As far as I've seen while googling it out. There's no obvious way to do that. Can anyone comment on that plz? Thanks in advance

      Rocky Success is a ladder which you can't climb with your hands in your pockets.

      K Offline
      K Offline
      Krish KP
      wrote on last edited by
      #2

      this can be done using either with Check Constraint or Trigger

      Regards KP

      R 1 Reply Last reply
      0
      • K Krish KP

        this can be done using either with Check Constraint or Trigger

        Regards KP

        R Offline
        R Offline
        Rocky
        wrote on last edited by
        #3

        oh yea, I just got this in mind a few minutes ago, Thanks:rose:

        Rocky Success is a ladder which you can't climb with your hands in your pockets.

        M 1 Reply Last reply
        0
        • R Rocky

          oh yea, I just got this in mind a few minutes ago, Thanks:rose:

          Rocky Success is a ladder which you can't climb with your hands in your pockets.

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Seems like a design nightmare. What is going to happen when the data grows past that number? Also you are breaking the cardinal rule of record identifiers, you are assigning intelligence to the ID field. Next I suppose you are going to sort by the id field!

          Never underestimate the power of human stupidity RAH

          R 1 Reply Last reply
          0
          • M Mycroft Holmes

            Seems like a design nightmare. What is going to happen when the data grows past that number? Also you are breaking the cardinal rule of record identifiers, you are assigning intelligence to the ID field. Next I suppose you are going to sort by the id field!

            Never underestimate the power of human stupidity RAH

            R Offline
            R Offline
            Rocky
            wrote on last edited by
            #5

            well I've asked almost the same question from the designers of the db but I'm still waiting for their response on this. But if they do insist I guess I'll have to say: As u say Mr. XXX :) Ur damn right:

            Mycroft Holmes wrote:

            Never underestimate the power of human stupidity

            Rocky Success is a ladder which you can't climb with your hands in your pockets.

            M 1 Reply Last reply
            0
            • R Rocky

              well I've asked almost the same question from the designers of the db but I'm still waiting for their response on this. But if they do insist I guess I'll have to say: As u say Mr. XXX :) Ur damn right:

              Mycroft Holmes wrote:

              Never underestimate the power of human stupidity

              Rocky Success is a ladder which you can't climb with your hands in your pockets.

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              Rocky# wrote:

              designers of the db

              Oh - you don't own the design :-O , poor bugger, my sincere sympathies.

              Never underestimate the power of human stupidity RAH

              R 1 Reply Last reply
              0
              • M Mycroft Holmes

                Rocky# wrote:

                designers of the db

                Oh - you don't own the design :-O , poor bugger, my sincere sympathies.

                Never underestimate the power of human stupidity RAH

                R Offline
                R Offline
                Rocky
                wrote on last edited by
                #7

                ahhh, well, its the designers themselves who r gona suffer at the end.haha :laugh: I pass ur sympaties to them

                Rocky Success is a ladder which you can't climb with your hands in your pockets.

                1 Reply Last reply
                0
                • R Rocky

                  hi everyone, I've a table in which the primary key needs to be a six digit number and must start from 1, so for that I made it an identity key (100001,1) but the problem is that I can't figure out how to restrict this to not exceed 199999 I'm using Sql Express 2005 as the Database. As far as I've seen while googling it out. There's no obvious way to do that. Can anyone comment on that plz? Thanks in advance

                  Rocky Success is a ladder which you can't climb with your hands in your pockets.

                  N Offline
                  N Offline
                  nelsonpaixao
                  wrote on last edited by
                  #8

                  i don´t know what you have in mind but if you trigger a SP to add data to one table, edit in that SP a if/else statement that counts the table records and; 1) add a record or 2) the display a error info message to the user. ;P

                  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