Auto-increment in SQL Server 2008 R2

413315 pts.
Tags:
SQL Server 2008 R2
SQL Server tables
I've just created a new table in SQL Server 2008 R2 and I'm trying to get the index on auto-increment. Is there a way to do this? 

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    I'm not sure to understand the question.
    Can you provide more details on what you are trying to do?
    77,155 pointsBadges:
    report
  • ITKE
    Thanks for the response Carlos. In the table, there's no identity data type, so I selected "int". I'm trying to define an INT column to be an identity. Does that make more sense?
    413,315 pointsBadges:
    report
  • carlosdl
    Oh, yes.

    That should be pretty easy. You just need to add the IDENTITY keyword with the appropriate parameters to your column definition.

    Something like this:

    CREATE TABLE yourTable (id INT IDENTITY(1,1));


    The parameters for the identity definition correspond to seed and increment.

    77,155 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: