Introduction:
Here I will explain how to create table with primary key in sql server or create table in sql server with primary key and identity or auto increment column with example. By setting column property like “UserID integer PRIMARY KEY IDENTITY” we can create primary key with identity column in sql server.
Here I will explain how to create table with primary key in sql server or create table in sql server with primary key and identity or auto increment column with example. By setting column property like “UserID integer PRIMARY KEY IDENTITY” we can create primary key with identity column in sql server.
Description:
In
previous articles I explained create error log files in asp.net, bind countries to dropdownlist in
asp.net,
SQL Server single procedure to
insert update delete, SQL Server take database backup, SQL Server restore database from
.bak / .mdf file, Primary key constraint in sql
server,
foreign key constraint in sql
server,
cursor example in sql server and many articles relating to SQL
server.
Now I will explain how to create table with primary key and identity column in sql
server.
To
create table with primary key and identity column we need to write the query
like as shown below in sql
server
Create Table
UserDetails
(
UserID integer
PRIMARY KEY IDENTITY,
UserName varchar(50),
Education varchar(50),
Location varchar(50)
)
|
When we run above query UserDetails table
will create in database that would be like as shown below
If you want to know more about
primary key / foreign key / other key constraints check following article it’s
having detailed explanation
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
0 comments :
Note: Only a member of this blog may post a comment.