about create table in sqlcommand

  • Thread starter Thread starter miladhatam
  • Start date Start date
M

miladhatam

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
 
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 äæÔÊå ÇÓÊ:
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))
oh thanks
i find this code
id INT NOT NULL IDENTITY PRIMARY KEY ,tex varchar ,topic varchar(25))
but your code is better
 
Back
Top