Click here to Skip to main content
15,909,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends ..
my requirement is i want to apply the primary key and identity to a column, when creating a table

here is my syntax
create table emp (eno int primary key identity(1,1) ,ename varchar(20))
Posted

1 solution

Please change the query to the following format

For Ms-Sql
SQL
create table emp (eno int not null identity(1,1) constraint pk_eno primary key,ename varchar(20)) 


For My-Sql
SQL
CREATE TABLE emp (
     eno INT NOT NULL AUTO_INCREMENT,
     ename VARCHAR(20),
     PRIMARY KEY (eno)
)



Hope it helps.
 
Share this answer
 
v3
Comments
yedhuvamshi 30-Sep-14 2:48am    
thank u so much it works.....
ChauhanAjay 30-Sep-14 2:58am    
Request you kindly accept the answer as solved.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900