RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums

Autonumber in a SQL Server table

Join Date: Jun 2005
Posts: 12
Reputation: relawson is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
relawson relawson is offline Offline
Newbie Poster

Re: Autonumber in a SQL Server table

  #5  
Jun 11th, 2005
Originally Posted by Paladine
Well kind of.

Ok here is the syntax on creating a table in SQL and having an autonumber column
CREATE TABLE NorthWindUsers 
         (UserID INT IDENTITY(1,1) NOT NULL,
          UserName VARCHAR(50) NOT NULL,
          Password VARCHAR(50) NOT NULL)

The userID will start a 1, and increment each time you add a new user to the table; automatically


Hope this helps


You know, this feature isn't in Oracle as I recently discovered. Is it considered bad to use autoincrementing numbers? Certainly makes it easy to maintain a primary key with little effort. I am just trying to understand in what situation you wouldn't want to use that feature. Obviously Oracle doesn't seem to want you to use it at all.
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:52 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC