automatic number problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fatih kayaalp

    automatic number problem

    Hi, i have imported an access database into sqlserver 2000. In access,
    i have some table fields which were using automatic number as
    datatype. But i see that there is not a datatype in sqlserver like
    automatic no. I have to enter id numbers to my tables for each records
    automatically. Would anybody help me about solving this problem? Any
    idea? Thanks
  • Erland Sommarskog

    #2
    Re: automatic number problem

    fatih kayaalp (kaya_alp@hotma il.com) writes:[color=blue]
    > Hi, i have imported an access database into sqlserver 2000. In access,
    > i have some table fields which were using automatic number as
    > datatype. But i see that there is not a datatype in sqlserver like
    > automatic no. I have to enter id numbers to my tables for each records
    > automatically. Would anybody help me about solving this problem? Any
    > idea? Thanks[/color]

    You can assign a column the IDENTITY property:

    CREATE TABLE a (a int IDENTITY(1, 1) NOT NULL,

    To get idenity value the most recently inserted row, use scope_identity( ).


    --
    Erland Sommarskog, SQL Server MVP, sommar@algonet. se

    Books Online for SQL Server SP3 at
    Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

    Comment

    • --CELKO--

      #3
      Re: automatic number problem

      >> I have some table fields [sic] which were using automatic number as
      datatype [sic]. <<

      You do not understand SQL or data modeling. Fields are not columns;
      tables are not file; rows are not records. The entire concept of a
      physical numbering of rows is not relational. Your original design
      was wrong and you want to copy it into SQL. Why do you want to do
      that again????

      Take a course and take the time to learn to do it right.

      Comment

      • Martin Feuersteiner

        #4
        Re: automatic number problem


        Joe, go back in the hole you came from, take an attitude course and then
        come back. Not earlier.

        "--CELKO--" <joe.celko@nort hface.edu> wrote in message
        news:a264e7ea.0 401132113.38222 a3a@posting.goo gle.com...[color=blue][color=green][color=darkred]
        > >> I have some table fields [sic] which were using automatic number as[/color][/color]
        > datatype [sic]. <<
        >
        > You do not understand SQL or data modeling. Fields are not columns;
        > tables are not file; rows are not records. The entire concept of a
        > physical numbering of rows is not relational. Your original design
        > was wrong and you want to copy it into SQL. Why do you want to do
        > that again????
        >
        > Take a course and take the time to learn to do it right.[/color]


        Comment

        • Erland Sommarskog

          #5
          Re: automatic number problem

          Martin Feuersteiner (theintrepidfox @hotmail.com) writes:[color=blue]
          > Joe, go back in the hole you came from, take an attitude course and then
          > come back. Not earlier.[/color]

          Joe on an attitude course? What a waste of time and money! That man is a
          hopeless case!

          --
          Erland Sommarskog, SQL Server MVP, sommar@algonet. se

          Books Online for SQL Server SP3 at
          Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

          Comment

          • Joe Celko

            #6
            Re: automatic number problem

            >> Joe on an attitude course? What a waste of time and money! That man
            is a hopeless case! <<

            I was going to take a Dale Carnegie course, but the restraining order is
            still in effect.

            --CELKO--
            =============== ============
            Please post DDL, so that people do not have to guess what the keys,
            constraints, Declarative Referential Integrity, datatypes, etc. in your
            schema are.

            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            Working...