about create table in sqlcommand

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
 
G

Guest

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))
 
M

miladhatam

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top