Handcoding SQL Autonumber

Results 1 to 2 of 2

Thread: Handcoding SQL Autonumber

  1. #1
    Max W. Guest

    Default Handcoding SQL Autonumber

    &nbsp;<BR>Hi --<BR><BR>I want to create a database completely from scratch using only SQL commands (for SQL Server).<BR><BR>I want to make a table, with the first column being an identity column that will autonumber itself, and be a primary key. Please tell me the EXACT code to accomplish this, based on the data below. Also, should this column be an Int, a LongInt, or other?<BR><BR>CUST_ID.....this is the identity col<BR>CUST_NAME...varchar(40)<BR>CUST_EMAIL..varc har(40)<BR><BR>Does this make sense?<BR><BR>CREATE TABLE CUSTOMER (<BR> CUST_ID INTEGER, NOT NULL, IDENTITY(1,1), PRIMARY KEY,<BR> CUST_NAME VARCHAR (40),<BR> CUST_EMAIL VARCHAR (40)<BR> );<BR><BR>Any help is appreciated... I am sure my syntax is outright wrong or redundant...<BR><BR>Sincerely,<BR><BR>Max Wilkinson<BR><BR><BR><BR>

  2. #2
    he Guest

    Default RE: Handcoding SQL Autonumber

    Looks good, but you may have a few too many commas:<BR>CREATE TABLE CUSTOMER (<BR>CUST_ID INTEGER NOT NULL IDENTITY(1,1) PRIMARY KEY,<BR>CUST_NAME VARCHAR (40),<BR>CUST_EMAIL VARCHAR (40)<BR>);<BR><BR>The integer may save space but on todays computers I would go for the long int. It&#039s up to you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts