Guruji Point - Code You Want To Write

  • Home
  • Asp.Net
  • WCF
  • SQL
  • Type Script
  • AngularJS
  • Tech News
  • Blog
  • Earn Online

Sunday, 15 January 2017

Define Auto Increment Primary Key In SQL Server

 No comments   

Introduction

In this article i will explain about How to define a Auto incremented Primary Key in table. 

Practice

You all are familiar with he Primary Key constraint and here i am using an additional keyword named IDENTITY for performing this operation.

The First Primary Key as its name implies it allows only Unique values and also don't allow to null values.Means if we define a column using Primary key then no value of this column can repeat and never same. We have only one Primary key in a single table.

The second one is IDENTITY which informs SQL server to auto increment numeric values with in a specified column after inserting any new record.

  CREATE TABLE  EmpDetail
         (
           Id  INT  NOT NULL IDENTITY  PRIMARY KEY, 
           Name VARCHAR(50),
           Designation VARCHAR(50)
            )



After this table creation , any time the insertion operation performed for the table then Id column automatically incremented by 1. This is very useful when you want to indexing your data. And some times there is need to count total records and find the particulate row record set .  
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Facebook Updates

Guruji Point

Categories

Comman table Expression in SQL Dynamic Grid Row IQueryable in c# Learn AngularJS Scope_Identity() Use of indexes comma seperated string in sql row_number() and dense_rank() salary table structure. while loop in sql why do we need cursor why tuple used

About Us

This blog is about the Programming ,Tech News and some intresting facts related Contents. Here you can find fundamental and expert level topic of programming languages very practically related to C# , Asp.Net ,Sql-Server, JavaScript, Jquery, WebServices And also Web-Api, WCF ,WPF, Angular Js.

Contact Us

Email Us - gurujipoints@gmail.com
Contact- 8077657477

Reach Us

Copyright © Guruji Point - Code You Want To Write