Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 22nd, 2007, 10:16 PM
Registered User
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default auto increment primary key

Does anyone know how to have the primary key column in a table be set to auto increment. (i.e. the other two columns (first_name, last_name are filled in, and the first column "id" is the primary key and is not manually filled in, but instead given an int value) I am using Microsoft SQL Server Managment Studio Express 2005 and am stuck on this problem.

Old May 22nd, 2007, 10:48 PM
Registered User
Join Date: May 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to TheAndruu

You can do this through the properties window. Right click the User table and select Modify. Now select the 'id' column and look at the properties window at the bottom of your screen.

In the properties you'll see an Identity Specification attribute with a '+' sign next to it. Click on the plus sign and where it says (Is Identity), change it from a 'No' to a 'Yes'.

You'll notice that the change also updates the Identity Increment and Identity Seed properties (both should be 1, most likely, for your purposes).

Hope this solves your problem,

Andrew C
Old June 3rd, 2007, 09:04 AM
Registered User
Join Date: May 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

creat table tablename
  id int identity(1,1),
  first_name char(8),
  last_name char(8)

try it on

Similar Threads
Thread Thread Starter Forum Replies Last Post
Increment a primary key bvpsekhar MySQL 7 May 9th, 2007 07:09 AM
SQL query to find key when auto-increment SandyFeder SQL Server ASP 1 November 21st, 2005 10:49 AM
How to auto increment primary key method SQL Server 2000 5 May 24th, 2005 03:25 PM
auto gerate of primary key Abhinav_jain_mca SQL Server 2000 15 October 1st, 2004 05:51 AM
auto increment primary key-compile error junemo Oracle 2 June 16th, 2004 08:53 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.