about create table in sqlcommand

Discussion in 'ASP .Net' started by miladhatam@gmail.com, Feb 1, 2007.

  1. Guest

    hi
    i know how can i create a table with sql command
    but i don't know how create a field with type integer ,autoNumber
    (auto increase) and Primary key
    Like id field in Access

    may you change below code with add a field with above properties
    Create Table " + TextBox1.Text + "(tex varchar ,topic
    varchar(25)PRIMARY KEY)
    thanks
    , Feb 1, 2007
    #1
    1. Advertising

  2. Hello miladhatam,

    What I think you're asking is how to create a table with a primary key that
    is also an identity column. The following statement creates the MyCustomers
    table with a CustID field/column as the primary key as an IDENTITY integer
    which starts at 100 and increases at an increment of 1. It also has a
    CompanyName column. Check out SQL Online Books:

    CREATE TABLE MyCustomers (CustID INTEGER IDENTITY (100,1) PRIMARY KEY,
    CompanyName NvarChar (50))

    --
    brians
    http://www.limbertech.com


    "" wrote:

    > hi
    > i know how can i create a table with sql command
    > but i don't know how create a field with type integer ,autoNumber
    > (auto increase) and Primary key
    > Like id field in Access
    >
    > may you change below code with add a field with above properties
    > Create Table " + TextBox1.Text + "(tex varchar ,topic
    > varchar(25)PRIMARY KEY)
    > thanks
    >
    >
    =?Utf-8?B?YnJpYW5zW01DU0Rd?=, Feb 1, 2007
    #2
    1. Advertising

  3. Guest

    brians äæÔÊå ÇÓÊ:
    > Hello miladhatam,
    >
    > What I think you're asking is how to create a table with a primary key that
    > is also an identity column. The following statement creates the MyCustomers
    > table with a CustID field/column as the primary key as an IDENTITY integer
    > which starts at 100 and increases at an increment of 1. It also has a
    > CompanyName column. Check out SQL Online Books:
    >
    > CREATE TABLE MyCustomers (CustID INTEGER IDENTITY (100,1) PRIMARY KEY,
    > CompanyName NvarChar (50))
    >
    > --
    > brians
    > http://www.limbertech.com
    >
    >
    > "" wrote:
    >
    > > hi
    > > i know how can i create a table with sql command
    > > but i don't know how create a field with type integer ,autoNumber
    > > (auto increase) and Primary key
    > > Like id field in Access
    > >
    > > may you change below code with add a field with above properties
    > > Create Table " + TextBox1.Text + "(tex varchar ,topic
    > > varchar(25)PRIMARY KEY)
    > > thanks
    > >
    > >

    oh thanks
    i find this code
    id INT NOT NULL IDENTITY PRIMARY KEY ,tex varchar ,topic varchar(25))
    but your code is better
    , Feb 1, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julian Bowes
    Replies:
    0
    Views:
    666
    Julian Bowes
    Jul 1, 2003
  2. Adhik
    Replies:
    1
    Views:
    5,020
    Patrick Steele [MVP]
    Jul 19, 2003
  3. =?Utf-8?B?VHJhY2V5?=

    Urgent: I can't update database with SqlCommand

    =?Utf-8?B?VHJhY2V5?=, May 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,231
    Alec MacLean
    May 5, 2004
  4. =?Utf-8?B?SklNLkgu?=

    SqlCommand is not defined.

    =?Utf-8?B?SklNLkgu?=, Jul 23, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    5,267
    Jordan
    Jul 23, 2004
  5. Winshent
    Replies:
    0
    Views:
    488
    Winshent
    Dec 14, 2004
Loading...

Share This Page